Jump to content

Making a script listen to vector


ayamashi
 Share

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

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

Recommended Posts

Hello, 

I've been practicing my scripting, but hit a small bump. 

 

I wanted to create two objects, one touch start to announce its position in sim on_rez with llGetPos(), and one with a listener that will listen to the position and move to the position on changed_link (avatar sit). 

 

I have tried googling as to how to make a script to listen, but haven't found any answer. 

 

I know how to make it listen to specified messages, like (if message = "Blue"), but have no idea how to make it listen to a vector? 

 

 

Thanks. 

Link to comment
Share on other sites

14 hours ago, Rolig Loon said:

Send the vector as a string and then recast it when it's received:

llRegionSay(secret_channel, (string)llGetPos() );

and then

listen (integer channel, string name, key id, string message)

{

    vector vReceived_vector = (vector)message;

}

Thanks Rolig! That did it.

Link to comment
Share on other sites

Here's a small wrench to throw in:

If the message that's received is NOT a valid vector, vReceived_vector will get ZERO_VECTOR as its value.

So, if your script is always listening, or might also receive non-vector messages, you may want to verify that the message that's received is actually supposed to be a vector.

The absolute simplest thing to start with is to see if the message begins and ends with < >, to at least have an idea if it could be a valid vector. The useful snippets section on the wiki has a convenient function to do everything.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

5 minutes ago, Wulfie Reanimator said:

Here's a small wrench to throw in:

If the message that's received is NOT a valid vector, vReceived_vector will get ZERO_VECTOR as its value.

So, if your script is always listening, or might also receive non-vector messages, you may want to verify that the message that's received is actually supposed to be a vector.

The absolute simplest thing to start with is to see if the message begins and ends with < >, to at least have an idea if it could be a valid vector. The useful snippets section on the wiki has a convenient function to do everything.

By all means.  I assume that any scripter will automatically think of the potential monkey wrenches, and will code safeguards to dodge around them. Check to be sure that the message is coming from a reliable source, that it's within the range of "acceptable" messages, that it isn't a duplicate of one that you have already received ....

  • Thanks 1
Link to comment
Share on other sites

11 minutes ago, Rolig Loon said:

By all means.  I assume that any scripter will automatically think of the potential monkey wrenches, and will code safeguards to dodge around them. Check to be sure that the message is coming from a reliable source, that it's within the range of "acceptable" messages, that it isn't a duplicate of one that you have already received ....

a55b678b35.png

  • Haha 2
Link to comment
Share on other sites

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