Difference between revisions of "LlAvatarOnSitTarget"
Jump to navigation
Jump to search
All Issues ~ Search JIRA for related Bugs
(Undo revision 43962 by Xenex Habilis (Talk) Not the french subpage) |
m (add CHANGED_LINK from the example to the also_articles, change to LSL tags from PRE tags) |
||
Line 7: | Line 7: | ||
*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<sup>[[#Notes|1]]</sup>. | *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<sup>[[#Notes|1]]</sup>. | ||
|spec | |spec | ||
|examples=< | |examples=<lsl> | ||
default | default | ||
{ | { | ||
Line 25: | Line 25: | ||
} | } | ||
} | } | ||
</ | </lsl> | ||
|helpers=< | |helpers=<lsl> | ||
//Gets the link number of a seated avatar | //Gets the link number of a seated avatar | ||
integer GetAgentLinkNumber(key avatar) | integer GetAgentLinkNumber(key avatar) | ||
Line 40: | Line 40: | ||
return 0x7FFFFFFF;//max int. | return 0x7FFFFFFF;//max int. | ||
}//Written by Strife Onizuka | }//Written by Strife Onizuka | ||
</ | </lsl> | ||
|related | |related | ||
|also_tests | |also_tests | ||
Line 46: | Line 46: | ||
|also_functions={{LSL DefineRow||[[llSitTarget]]|}} | |also_functions={{LSL DefineRow||[[llSitTarget]]|}} | ||
{{LSL DefineRow||[[llGetLinkKey]]}} | {{LSL DefineRow||[[llGetLinkKey]]}} | ||
|also_articles | |also_articles={{LSL DefineRow||[[CHANGED_LINK]]|}} | ||
|notes= | |notes= | ||
#To scan a link set using a function such as [[llGetLinkKey]] (see [[llGetNumberOfPrims#Useful_Snippets]] for examples). | #To scan a link set using a function such as [[llGetLinkKey]] (see [[llGetNumberOfPrims#Useful_Snippets]] for examples). |
Revision as of 20:44, 8 January 2008
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: key llAvatarOnSitTarget( );239 | Function ID |
0.0 | Forced Delay |
10.0 | Energy |
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 set1.
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 not NULL_KEY or invalid 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 linkNum = 1 + llGetNumberOfPrims(); key linkKey; //Next we get the linkKey and make sure it's not null, if it's null we are done. while((linkKey = llGetLinkKey( --linkNum )))//is the key valid? if(avatar == linkKey)//is it the avatar we want? return linkNum;//It's the avatar we want so return. //avatar wasn not found //return a number that isn't a LINK_* flag not a valid link number either. return 0x7FFFFFFF;//max int.
}//Written by Strife Onizuka </lsl>
Notes
- To scan a link set using a function such as llGetLinkKey (see llGetNumberOfPrims#Useful_Snippets for examples).
- The position of an avatar on a sit target can be determined with the use of llGetObjectDetails (see llSitTarget#Useful_Snippets for example).