Difference between revisions of "LlSitTarget"
Jump to navigation
Jump to search
Line 25: | Line 25: | ||
UpdateSitTarget(vector pos, rotation rot) | UpdateSitTarget(vector pos, rotation rot) | ||
{ | { | ||
key | key user = llAvatarOnSitTarget(); | ||
if(a | if(user)//true if there is a user seated on the sittarget, if so update their position | ||
llSetLinkPrimitiveParams(GetAgentLinkNumber( | 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 | integer GetAgentLinkNumber(key avatar) | ||
{ | { | ||
integer | integer linkNum = 1 + llGetNumberOfPrims(); | ||
if(linkNum > 2) | |||
if( | { | ||
while(llGetAgentSize( | key linkKey; | ||
if( | //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 | 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
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: llSitTarget( vector offset, rotation rot );238 | Function ID |
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 |
Caveats
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