Jump to content

Pass simple variable (integer) to another script


Ronie5ive
 Share

You are about to reply to a thread that has been inactive for 3801 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

If the two scripts are in the same link set or prim, use llMessageLInked(...). The receiving script must have a link_message event declared. You can either convert the integer to a string and pass it as the message, or put it as the message number and let the receiving script simply grab the number.

A mistake I frequently made when using llMessageLinked was to use LINK_ALL_OTHERS to say who was to get the message, and overlook the fact that if both scripts are in the same prim, you must use LINK_THIS instead.

if the two scripts are in separate objects, one will have to llSay(...) the string value of the inthger, the other must be listening on the same channel used in the llSay , and converts the string message it heard to an integer.

 

The LSL wiki has examples of both these methids, look under communications. It is also worth looking at llRegionSayTo if the two separate objects are going to be a long way apart.

  • Like 1
Link to comment
Share on other sites

If both a sending and a receiving scripts are in the same prim, the method is http://wiki.secondlife.com/wiki/LlMessageLinked

If a sending and a receiving scripts are in different prims of the same linkset, you may use either http://wiki.secondlife.com/wiki/LlMessageLinked or Listen mechanism

If a sending and a receiving scripts are in different linksets in the same region you should use the Listen

If a sending and a receiving script are in linksets located in different regions, either objects email or HTTP

  • Like 1
Link to comment
Share on other sites


Ronie5ive wrote:

Greetings, would anyone know a simple way to pass integer variables between scripts? Say I'd like to pass (integer t = 0) from script1 to script5, so that script5 has an integer named "t" which is equal to 0.

This depends on your scenario.  If the scripts are located in the same prim, or located in prims that are linked, you can use llMessageLinked.  If the scripts are located on prims that are not linked but are on same region, using llRegionSay or llRegionSayTo.  Which one you use depends if you will always know the UUID of the object your wanting it to talk to.

If they in different regions (such as wanting to talk to a hud attached to an avatar on a diffferent area) You will need to do a llHTTPRequest.  Basically one script wills end an http request to a page with coding that stores the information into a database.  script on second script is sending constant http requests to look for anything first script put up, then parses the result.

If they are in different regions AND the regions are connected, you can do a neat little trick with llRegionSay and llSay. Place two objects near eachother on a sim boundary. set them so they listen on a negative channel, and anything they hear, they repeat that same thing on a second negative channel using llSay. if they hear something on that secodn negativ channel, they repeat it with llRegionSay instead

Now, say you have two objects you want to be able to talk to eachother, no matter which of the connceted sim they are on. When they speak they simply send a llRegionSay on that negative channel from earlier.  If objects are in same sim, they hear eachother. if on different sims, the boundary object hears it, repeats it with llSay so the object in adjoining region hears it,and that object repeats it using llRegionSay. You could end up linking several connected sims this way :)

 

In any event, those are the options of coding to use

 

  • Like 1
Link to comment
Share on other sites

The others have explained how to pass a (string) message.  If you want to encode more than just an integer value within that string (eg; send "t=0" rather than just "0") there are two options:

In either case you can't create variables by name so, unless you already have an integer variable called "t" you won't be able to use it.  JSON would probably be best here since you can associate values with keys and then use the JSON functions to retrieve the values.

  • Like 1
Link to comment
Share on other sites

Thanks everyone for your input. I'm looking into llRegionSayTo which may be better to use but unfortunately I'm not exactly sure how to use it (still a newbie at Linden Language). Every example I see online doesn't fully explain how to use it (even the wiki).

What I need to make happen all goes within a listening event. So if a message is heard from a prim, then loop play a sound until the user clicks a notecard dialog option. I've tried using another listening event within the existing listening event but it seems that is not possible. LlMessageLinked would do the job well, but the primary object I need to link rotates around the x-axis; linking it to another object throws the rotation off.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3801 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...