Difference between revisions of "LlSitTarget"

From Second Life Wiki
Jump to navigation Jump to search
Line 22: Line 22:
</pre>
</pre>
|helpers=<pre>
|helpers=<pre>
//Coming soon
//Sets / Updates the sit target moving the avatar on it if necessary.
UpdateSitTarget(vector pos, rotation rot)
{
    llSitTarget(pos, rot);//Set the sit target
    key user = llAvatarOnSitTarget();
    if(user)//true if there is a user seated on the sittarget, if so update their position
    {
        vector size = llGetAgentSize(user);
        if(size)//This tests to make sure the user really exists.
        {
            //We need to make the position and rotation local to the current prim
            integer linkNum = 1 + llGetNumberOfPrims();
            do;while(linkNum && user != llGetLinkKey( --linkNum ));//find the users link number
            rotation localrot = llGetLocalRot();
            pos.z += 0.4 - size.z * 0.02638;
            llSetLinkPrimitiveParams(linkNum,
                                    [PRIM_POSITION, (pos * localrot) + llGetLocalPos(),
                                    PRIM_ROTATION, rot * localrot / llGetRootRotation()]);
        }
        else
        {//It is rare that the sit target will bork but it does happen, this can help to fix it.
            llUnSit(user);
        }
    }
}//Written by Strife Onizuka, size adjustment Escort DeFarge
</pre>
</pre>
|also_functions={{LSL DefineRow||{{LSLG|llSetSitText}}|}}
|also_functions={{LSL DefineRow||{{LSLG|llSetSitText}}|}}

Revision as of 15:52, 30 April 2007

Summary

Function: llSitTarget( vector offset, rotation rot );
0.0 Forced Delay
10.0 Energy

Set the sit location for this object (if offset == <0.0, 0.0, 0.0> clear it)

• vector offset
• rotation rot

Examples

default
{
    state_entry()
    {
        llSitTarget(<0.0, 0.0, 1.0>, ZERO_ROTATION); //The vector's components must not all be set to 0 for effect to take place.
    }
}

Useful Snippets

//Sets / Updates the sit target moving the avatar on it if necessary.
UpdateSitTarget(vector pos, rotation rot)
{
    llSitTarget(pos, rot);//Set the sit target
    key user = llAvatarOnSitTarget();
    if(user)//true if there is a user seated on the sittarget, if so update their position
    {
        vector size = llGetAgentSize(user);
        if(size)//This tests to make sure the user really exists.
        {
            //We need to make the position and rotation local to the current prim
            integer linkNum = 1 + llGetNumberOfPrims();
            do;while(linkNum && user != llGetLinkKey( --linkNum ));//find the users link number
            rotation localrot = llGetLocalRot();
            pos.z += 0.4 - size.z * 0.02638;
            llSetLinkPrimitiveParams(linkNum,
                                    [PRIM_POSITION, (pos * localrot) + llGetLocalPos(),
                                     PRIM_ROTATION, rot * localrot / llGetRootRotation()]);
        }
        else
        {//It is rare that the sit target will bork but it does happen, this can help to fix it.
            llUnSit(user);
        }
    }
}//Written by Strife Onizuka, size adjustment Escort DeFarge

See Also

Events

•  changed

Functions

•  llSetSitText
•  llAvatarOnSitTarget
•  llUnSit

Deep Notes

Signature

function void llSitTarget( vector offset, rotation rot );