Difference between revisions of "LlAvatarOnSitTarget"

From Second Life Wiki
Jump to navigation Jump to search
(Undo revision 43962 by Xenex Habilis (Talk) Not the french subpage)
Line 2: Line 2:
|func=llAvatarOnSitTarget
|func=llAvatarOnSitTarget
|return_type=key
|return_type=key
|return_text= :Retourne le [[UUID]] de l'avatar assis sur le prim.
|return_text=that is the [[UUID]] of the user seated on the prim.
|func_footnote=SI le prim ne trouve pas de 'sit target' ou si il n'y a pas d'avatar assis sur le prim, alors {{LSL Const|NULL_KEY|key|"00000000-0000-0000-0000-000000000000"|c=Evaluates to false in conditionals just like invalid keys.}} est retourné.
|func_footnote=If the prim lacks a 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.
|caveats=*Un prim n'a pas de 'sit target' sans que [[llSitTarget]] soit crée avec un vecteur '''non nul'''.
|caveats=*A prim does not have a sit target unless [[llSitTarget]] has been called with a '''nonzero''' vector as the first argument.
*Si le prim ne trouve pas de 'sit target' ou si l'avatar est assis sur un prim different,la seule façon de determiner combien et quel avatar est assis sur l'objet est de scanner le 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=<pre>
|examples=<pre>
Line 12: Line 12:
     state_entry()
     state_entry()
     {
     {
         // Creation du sit target, sinon la fonction ne marche pas
         // set sit target, otherwise this will not work
         llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION);
         llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION);
     }
     }
Line 19: Line 19:
         if (change & CHANGED_LINK) {  
         if (change & CHANGED_LINK) {  
             key av = llAvatarOnSitTarget();
             key av = llAvatarOnSitTarget();
             if (av) {//VRAI si la clé de l'avatar existe et est valide
             if (av) {//evaluated as true if not NULL_KEY or invalid
                 llSay(0, "Salut " + llKey2Name(av) + ", Merci de vous etre assis");
                 llSay(0, "Hello " + llKey2Name(av) + ", thank you for sitting down");
             }
             }
         }
         }
Line 27: Line 27:
</pre>
</pre>
|helpers=<pre>
|helpers=<pre>
//Donne le numero de link de l'avatar assis
//Gets the link number of a seated avatar
integer GetAgentLinkNumber(key avatar)
integer GetAgentLinkNumber(key avatar)
{
{
     integer linkNum = 1 + llGetNumberOfPrims();
     integer linkNum = 1 + llGetNumberOfPrims();
     key linkKey;
     key linkKey;
     //Apres nous prendrond le linkKey soyez sur qu'il est non nul sinon cela ne marchera pas.
     //Next we get the linkKey and make sure it's not null, if it's null we are done.
     while((linkKey = llGetLinkKey( --linkNum )))//est ce que la clé est valide?
     while((linkKey = llGetLinkKey( --linkNum )))//is the key valid?
         if(avatar == linkKey)//est ce le bon avatar?
         if(avatar == linkKey)//is it the avatar we want?
             return linkNum;//C'est le bon avatar.
             return linkNum;//It's the avatar we want so return.
     //L'avatar n'a pas été trouvé
     //avatar wasn not found
     //retounre un nombre, ce n'est pas une balise LINK_* ni un numero de link valide.
     //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 48: Line 48:
|also_articles
|also_articles
|notes=
|notes=
#Pour scanner un link set utliser une fonction comme [[llGetLinkKey]] (voir [[llGetNumberOfPrims#Useful_Snippets]]comme exemple).
#To scan a link set using a function such as [[llGetLinkKey]] (see [[llGetNumberOfPrims#Useful_Snippets]] for examples).
#La position d'un avatar assis sur un prim peut etre determiné avec [[llGetObjectDetails]] (voir [[llSitTarget#Useful_Snippets]]comme exemple).
#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 09:41, 8 December 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

  • 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.
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();