Difference between revisions of "LlSitTarget"
Jump to navigation
Jump to search
(Major change, makes it work properly for non-zero rotations.) |
|||
Line 36: | Line 36: | ||
if(llGetLinkNumber() > 1)//only need the local rot if it's not the root. | if(llGetLinkNumber() > 1)//only need the local rot if it's not the root. | ||
localrot = llGetLocalRot(); | localrot = llGetLocalRot(); | ||
pos.z += 0.4 | pos.z += 0.4; | ||
integer linkNum = llGetNumberOfPrims(); | integer linkNum = llGetNumberOfPrims(); | ||
do{ | do{ | ||
Line 42: | Line 42: | ||
{ | { | ||
llSetLinkPrimitiveParams(linkNum, | llSetLinkPrimitiveParams(linkNum, | ||
[PRIM_POSITION, (pos * localrot) + llGetLocalPos(), | [PRIM_POSITION, ((pos - (llRot2Up(rot) * size.z * 0.02638)) * localrot) + llGetLocalPos(), | ||
PRIM_ROTATION, rot * localrot / llGetRootRotation()]); | PRIM_ROTATION, rot * localrot / llGetRootRotation()]); | ||
jump end;//cheaper but a tad slower then return | jump end;//cheaper but a tad slower then return |
Revision as of 18:19, 4 May 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) { 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 rotation localrot = ZERO_ROTATION; if(llGetLinkNumber() > 1)//only need the local rot if it's not the root. localrot = llGetLocalRot(); pos.z += 0.4; integer linkNum = llGetNumberOfPrims(); do{ if(user == llGetLinkKey( linkNum ))//just checking to make sure the index is valid. { llSetLinkPrimitiveParams(linkNum, [PRIM_POSITION, ((pos - (llRot2Up(rot) * size.z * 0.02638)) * localrot) + llGetLocalPos(), PRIM_ROTATION, rot * localrot / llGetRootRotation()]); jump end;//cheaper but a tad slower then return } }while( --linkNum ); } else {//It is rare that the sit target will bork but it does happen, this can help to fix it. llUnSit(user); } } @end; }//Written by Strife Onizuka, size adjustment Escort DeFarge