Difference between revisions of "LlAvatarOnSitTarget"

From Second Life Wiki
Jump to navigation Jump to search
m (added ref to llGetLinkname)
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 sit target or there is no avatar sitting on the prim, then {{LSLG|NULL_KEY}} is returned.
|func_footnote=If the prim lacks a sit target or there is no avatar sitting on the prim, then [[NULL_KEY]] is returned.
|caveats=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 using a function such as [[llGetLinkName]].
|caveats=*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=<pre>
|examples=<pre>
Line 35: Line 35:
         if(avatar == linkKey)//is it the avatar we want?
         if(avatar == linkKey)//is it the avatar we want?
             return linkNum;//It's the avatar we want so return.
             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.
     //avatar wasn not found
    //return a number that isn't a LINK_* flag not a valid link number either.
     return 0x7FFFFFFF;//max int.
     return 0x7FFFFFFF;//max int.
}//Written by Strife Onizuka
}//Written by Strife Onizuka
Line 45: Line 46:
{{LSL DefineRow||[[llGetLinkKey]]}}
{{LSL DefineRow||[[llGetLinkKey]]}}
|also_articles
|also_articles
|notes
|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).
|cat1=Avatar
|cat1=Avatar
|cat2=Prim
|cat2=Prim

Revision as of 19:23, 3 September 2007

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

  • 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.
All Issues ~ Search JIRA for related Bugs

Examples

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");
            }
        }
    }
}

Useful Snippets

//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

Notes

  1. To scan a link set using a function such as llGetLinkKey (see llGetNumberOfPrims#Useful_Snippets for examples).
  2. The position of an avatar on a sit target can be determined with the use of llGetObjectDetails (see llSitTarget#Useful_Snippets for example).

See Also

Events

•  changed

Functions

•  llSitTarget
•  llGetLinkKey

Deep Notes

Search JIRA for related Issues

Signature

function key llAvatarOnSitTarget();