Difference between revisions of "LlSitTarget"

From Second Life Wiki
Jump to navigation Jump to search
Line 6: Line 6:
|p2_type=rotation|p2_name=rot|p2_desc
|p2_type=rotation|p2_name=rot|p2_desc
|func_footnote
|func_footnote
|func_desc=Set the sit location for this object (if '''offset''' == {{LSLG|ZERO_VECTOR|<0.0, 0.0, 0.0>}} clear it)
|func_desc=Set the sit location for this object (if '''offset''' == [[ZERO_VECTOR|{{LSL VR|0.0|0.0|0.0}}]] clear it)
|return_text
|return_text
|spec
|spec
|caveats=*If the sit target is <0,0,0>, then llAvatarOnSitTarget() will return NULL_KEY. There does not appear to be a way to disable the pie menu item for sit. (Confirmation?)
|caveats=*If the sit target is <0,0,0>, then llAvatarOnSitTarget() will return {{LSL_Constant/NULL_KEY}}.
*There is no way to remove the Sit option from the pie menu.
**It will appear to be removed if the the [[llSetSitText|sit text]] value is set to a space "&nbsp;".
|constants
|constants
|examples=
|examples=
Line 74: Line 76:
     return [];
     return [];
}//Written by Strife Onizuka</lsl>
}//Written by Strife Onizuka</lsl>
|also_functions={{LSL DefineRow||{{LSLG|llSetSitText}}|}}
|also_functions={{LSL DefineRow||[[llSetSitText]]|}}
{{LSL DefineRow||{{LSLG|llAvatarOnSitTarget}}|}}
{{LSL DefineRow||[[llAvatarOnSitTarget]]|}}
{{LSL DefineRow||{{LSLG|llUnSit}}|}}
{{LSL DefineRow||[[llUnSit]]|}}
|also_events={{LSL DefineRow||{{LSLG|changed}}|}}
|also_events={{LSL DefineRow||[[changed]]|}}
|also_articles
|also_articles
|notes
|notes
|permission
|negative_index
|cat1=Sit
|cat1=Sit
|cat2=Vehicle
|cat2=Vehicle

Revision as of 18:16, 23 March 2008

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

Caveats

  • If the sit target is <0,0,0>, then llAvatarOnSitTarget() will return NULL_KEY.
  • There is no way to remove the Sit option from the pie menu.
    • It will appear to be removed if the the sit text value is set to a space " ".
All Issues ~ Search JIRA for related Bugs

Examples

<lsl>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.
   }
}</lsl>

Useful Snippets

UpdateSitTarget

<lsl>//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;
           vector localpos = ZERO_VECTOR;
           if(llGetLinkNumber() > 1)//only need the local rot if it's not the root.
           {
               localrot = llGetLocalRot();
               localpos = llGetLocalPos();
           }
           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) + localpos,
                                            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 provided by Escort DeFarge</lsl>

GetSitTarget

<lsl>list GetSitTarget(integer prim, key av) {//WARNING: llGetObjectDetails can introduce an error that goes as far as the 5th decimal place.

   vector tp = llGetAgentSize(av);
   if(tp)
   {
       if(prim == LINK_THIS)//llGetLinkKey doesn't like LINK_THIS
           prim = llGetLinkNumber();
       
       list details = [OBJECT_POS, OBJECT_ROT];
       rotation f = llList2Rot(details = (llGetObjectDetails(llGetLinkKey(prim), details) + llGetObjectDetails(av, details)), 1);
       rotation r = llList2Rot(details, 3) / f;
       return [((llList2Vector(details, 2) - llList2Vector(details, 0)) / f) + (llRot2Up(r) * tp.z * 0.02638) - <0.0, 0.0, 0.4>, r];
   }
   return [];

}//Written by Strife Onizuka</lsl>

See Also

Events

•  changed

Functions

•  llSetSitText
•  llAvatarOnSitTarget
•  llUnSit

Deep Notes

Search JIRA for related Issues

Signature

function void llSitTarget( vector offset, rotation rot );