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>
//Sets / Updates the sit target moving the avatar on it if necessary.
//Coming soon
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
</pre>
</pre>
|also_functions={{LSL DefineRow||{{LSLG|llSetSitText}}|}}
|also_functions={{LSL DefineRow||{{LSLG|llSetSitText}}|}}

Revision as of 12:15, 28 April 2007