Difference between revisions of "LlAvatarOnSitTarget"

From Second Life Wiki
Jump to navigation Jump to search
m
m (better on llSitTarget)
Line 3: Line 3:
|return_type=key
|return_type=key
|return_text=that is the [[UUID]] of the user seated on the prim.
|return_text=that is the [[UUID]] of the user seated on the prim.
|func_footnote=If the prim lacks a [[llSitTarget|sit target]] or there is no avatar sitting on the prim, then {{LSL Const|NULL_KEY|key|"00000000-0000-0000-0000-000000000000"|c=Evaluates to false in conditionals just like invalid keys.}} is returned.
|func_footnote=If the prim lacks a [[llSitTarget|sit target]] or there is no avatar sitting on the prim, then {{LSL Constant/NULL_KEY}} is returned.
|caveats=*A prim does not have a sit target unless [[llSitTarget]] has been called with a '''nonzero''' vector as the first argument.
|caveats=*A prim does not have a sit target unless [[llSitTarget]] has been called with a '''nonzero''' vector as the first argument.
*If the prim lacks a sit target or the avatar is seated upon a different prim, the only way to determine how many and which avatars are seated upon the object is to scan the link set (for an example of this, see [[llGetNumberOfPrims#Useful_Snippets|llGetNumberOfPrims]]).
*If the prim lacks a sit target or the avatar is seated upon a different prim, the only way to determine how many and which avatars are seated upon the object is to scan the link set (for an example of this, see [[llGetNumberOfPrims#Useful_Snippets|llGetNumberOfPrims]]).
Line 56: Line 56:
|cat3=Sit
|cat3=Sit
|cat4
|cat4
|haiku={{Haiku|The seats all taken.|Perch on the tailgait I try.|On the hood I sit.}}
}}
}}

Revision as of 21:27, 27 July 2013

Summary

Function: key llAvatarOnSitTarget( );

Returns a key that is the UUID of the user seated on the prim.

If the prim lacks a sit target or there is no avatar sitting on the prim, then NULL_KEY is returned.

Caveats

  • A prim does not have a sit target unless llSitTarget has been called with a nonzero vector as the first argument.
  • If the prim lacks a sit target or the avatar is seated upon a different prim, the only way to determine how many and which avatars are seated upon the object is to scan the link set (for an example of this, see llGetNumberOfPrims).
All Issues ~ Search JIRA for related Bugs

Examples

<lsl>default {

   state_entry()
   {
       // set sit target, otherwise this will not work 
       llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION);
   }
   changed(integer change)
   {
       if (change & CHANGED_LINK)
       { 
           key av = llAvatarOnSitTarget();
           if (av) // evaluated as true if key is valid and not NULL_KEY
           {
               llSay(0, "Hello " + llKey2Name(av) + ", thank you for sitting down");
           }
       }
   }
}</lsl>

Useful Snippets

<lsl>//Gets the link number of a seated avatar integer GetAgentLinkNumber(key avatar) {

   integer link_num = llGetNumberOfPrims();
   while (link_num > 1) // Check only child prims.
   {
       if (llGetLinkKey(link_num) == avatar) // If it is the avatar we want
       {
           return link_num; // then return the link number
       }
       --link_num; // else go on with next child.
   }
   // Avatar wasn't found
   return FALSE; // 0 (zero) for easy testing.

}</lsl>

Notes

The position of an avatar on a sit target can be determined with the use of llGetObjectDetails (see llSitTarget for an example).

See Also

Events

•  changed

Functions

•  llAvatarOnLinkSitTarget
•  llSitTarget
•  llLinkSitTarget
•  llGetLinkKey

Articles

•  CHANGED_LINK

Deep Notes

Search JIRA for related Issues

Signature

function key llAvatarOnSitTarget();