llSitTarget

From Second Life Wiki
Revision as of 10:11, 28 April 2007 by Strife Onizuka (talk | contribs)
Jump to navigation Jump to search

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)
{
    key user = llAvatarOnSitTarget();
    if(user)//true if there is a user seated on the sittarget, if so update their position
        llSetLinkPrimitiveParams(GetAgentLinkNumber(user), [PRIM_POSITION, llGetLocalPos() + (pos * llGetLocalRot()),
                                                         PRIM_ROTATION, rot *llGetLocalRot()]);
    llSitTarget(pos, rot);//Set the sit target
}//Written by Strife Onizuka

//Gets the link number of a seated avatar
integer GetAgentLinkNumber(key avatar)
{
    integer linkNum = 1 + llGetNumberOfPrims();
    if(linkNum > 2)
    {
        key linkKey;
        //Next we get the linkKey and make sure it's a user by requesting the agent size.
        while(llGetAgentSize(linkKey = llGetLinkKey( --linkNum )))
            if(linkKey == avatar)//It's an avatar, is it the avatar we want?
                return linkNum;//It's the avatar we want so return.
    }
    //avatar wasn't found so return a number that isn't a LINK_* flag that can't be a valid link number either.
    return 0x7FFFFFFF;//max int.
}//Written by Strife Onizuka

See Also

Events

•  changed

Functions

•  llSetSitText
•  llAvatarOnSitTarget
•  llUnSit

Deep Notes

Signature

function void llSitTarget( vector offset, rotation rot );