Jump to content

SLS_Help_Post_3


childhoodbestfriend489
 Share

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

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

Recommended Posts

How to make it correct?

 

default
{
    state_entry()
    {
        llListen(6, "", llGetOwner(), "");
    }
    
    listen( integer channel, string name, key id, string message )
    {   
         llSetStatus(STATUS_PHYSICS, TRUE);
         llMoveToTarget(message,100);
    }
}

 

How to make it correct?

Link to comment
Share on other sites

You must typecast message to a vector: llMoveToTarget((vector) message,100);

And when you chat the vector you need to be careful to get it exactly right. An invalid vector in the message will be converted to the ZERO_VECTOR <0.0, 0.0, 0.0>, and your object will wander off into the distance.

After that's happened a couple of times you might want to use this code snippet to test if the message string does represent a valid vector:

integer IsVector(string s)
{
    list split = llParseString2List(s, [" "], ["<", ">", ","]);
    if(llGetListLength(split) != 7)//we must check the list length, or the next test won't work properly.
        return FALSE;
    return !((string)((vector)s) == (string)((vector)((string)llListInsertList(split, ["-"], 5))));
    //it works by trying to flip the sign on the Z element of the vector,
    //if it works or breaks the vector then the values won't match.
    //if the vector was already broken then the sign flip will have no affect and the values will match
    //we cast back to string so we can catch negative zero which allows for support of ZERO_VECTOR
}//Strife Onizuka

 

Link to comment
Share on other sites

Also, note that the llMoveToTarget function will only work if you are wearing the object or if you have made it physical, and that it will not move an object more than 64 m.  Note also that the damping time, which you set to 100 seconds, is supposed to be a float, not an integer.  You can get away with the integer, because the compiler will typecast it implicitly, but the value really should be 100.0. 

Link to comment
Share on other sites

Also note that all the movement commands in LSL, other than directly setting position, are "best effort". Movement may get there. Movement may just get close. Movement may get stuck. Movement may overshoot (especially in overloaded sims). You have to check, if the final position matters.

  • Like 2
Link to comment
Share on other sites

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