Difference between revisions of "LlSitTarget"

From Second Life Wiki
Jump to navigation Jump to search
Line 25: Line 25:
UpdateSitTarget(vector pos, rotation rot)
UpdateSitTarget(vector pos, rotation rot)
{
{
     key a = llAvatarOnSitTarget();
     key user = llAvatarOnSitTarget();
     if(a)
     if(user)//true if there is a user seated on the sittarget, if so update their position
         llSetLinkPrimitiveParams(GetAgentLinkNumber(a), [PRIM_POSITION, llGetLocalPos() + (pos * llGetLocalRot()),
         llSetLinkPrimitiveParams(GetAgentLinkNumber(user), [PRIM_POSITION, llGetLocalPos() + (pos * llGetLocalRot()),
                                                         PRIM_ROTATION, rot *llGetLocalRot()]);
                                                         PRIM_ROTATION, rot *llGetLocalRot()]);
     llSitTarget(pos, rot);
     llSitTarget(pos, rot);//Set the sit target
}//Written by Strife Onizuka
}//Written by Strife Onizuka


//Gets the link number of a seated avatar
//Gets the link number of a seated avatar
integer GetAgentLinkNumber(key c)
integer GetAgentLinkNumber(key avatar)
{
{
     integer a = -~llGetNumberOfPrims();
     integer linkNum = 1 + llGetNumberOfPrims();
    key b;
     if(linkNum > 2)
     if(a > 2)
    {
         while(llGetAgentSize(b = llGetLinkKey(a = ~-a)))
        key linkKey;
             if(b == c)
        //Next we get the linkKey and make sure it's a user by requesting the agent size.
                 return a;
         while(llGetAgentSize(linkKey = llGetLinkKey( --linkNum )))
     return 0;
             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
}//Written by Strife Onizuka
</pre>
</pre>

Revision as of 11:11, 28 April 2007

Summary

Function: llSitTarget( vector offset, rotation rot );

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

Search JIRA for related Issues

Signature

function void llSitTarget( vector offset, rotation rot );