Jump to content

Integer transfer between scripts.


TessaAnnaMarie
 Share

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

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

Recommended Posts

So i need to send an integer from one script to another. 
I am using llTextBox to allow the player to enter a integer. I need to be able to pass that integer to another script in an unlinked prim.

I have been using llSay + Listen, i can make objects talk to one another no problem. What i can't figure out is how to allow the script to communicated the integer.

Basic run down. 
Cube is being click, pops up the text box. I enter 5. I can't even get that value to save as an integer.

Edited by TessaAnnaMarie
Link to comment
Share on other sites

39 minutes ago, Jenna Huntsman said:

Use a typecast as part of your listen:

integer myInt;

listen( integer channel, string name, key id, string message )
{
    if((integer)message) //check if message is an integer (and is not 0)
    {
        myInt = (integer)message
    }
}

 

Okay, i have in fact verified that it is being set as an integer. Now to send it to the other script?

Edited by TessaAnnaMarie
Link to comment
Share on other sites

Same thing as what Jenna posted. Typecast to a string (string)integer_value. And in the other prims listen what Jenna showed.

If that number is only relevant as an integer to the other prim, just send the string as is from TextBox, and just typecast to integer in that other prim.

Link to comment
Share on other sites

Just for clarification, messages sent by llSay, llShout, llWhisper, llRegionSay, llRegionSayTo, etc. will always be sent as strings. This includes llTextBox, which is actually sending the contents entered into the textbox as a chat message originating from the avatar itself. Similarly, any message a listening script hears in its listen event will always be received as a string. That's how the listen event is setup.

It is up to the receiving script to parse that string and convert it (or a portion of it) to the desired variable type. Conversion is done via the concept of typecasting as mentioned above. Since you're letting the user type in the number, you'll likely want to add some error checking to ensure the script doesn't lose its mind if the user sends something that isn't a number (or isn't within your range of expected values).

 

As an aside, llMessageLinked can send messages to linked prims within a linkset and has specific parameters for sending an integer, string, and key all in one message. The link_message event is this function's counterpart and can receive and distinguish those integer/string/key components from each other.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 802 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...