Difference between revisions of "LlGetAgentInfo"

From Second Life Wiki
Jump to navigation Jump to search
m (I had a script that I build mysel A to Z whit commants insides)
m (Added caveat)
 
(23 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{Issues/SVC-3177}}{{LSL Function/avatar|id|sim=*}}{{LSL_Function
{{LSL_Function
|inject-2={{Issues/SVC-91}}{{Issues/SVC-3177}}{{LSL Function/avatar|id|sim=*}}
|func=llGetAgentInfo
|func=llGetAgentInfo
|sort=GetAgentInfo
|sort=GetAgentInfo
|func_id=206|func_sleep=0.0|func_energy=10.0
|func_id=206|func_sleep=0.0|func_energy=10.0
|return_type=integer|p1_type=key|p1_name=id
|return_type=integer|return_subtype=bit field
|p1_type=key|p1_name=id
|func_footnote
|func_footnote
|func_desc
|func_desc
|return_text=bitfield containing the agent information about '''id'''.
|return_text=containing the agent information about {{LSLP|id}}.
|spec
|spec
|caveats=*[[AGENT_BUSY]] indicates that the "busy" [[Internal Animations|internal animation]] is playing, even if the user is not truly in busy mode.
|caveats=* [[AGENT_BUSY]] indicates that the "busy" [[Internal Animations|internal animation]] is playing, even if the user is not truly in busy mode.
* [[AGENT_TYPING]] indicates that the "typing" internal animation is playing, it will not be set if the user disables [[Debug Settings|PlayTypingAnim]].
* '''On server 1.40 and below''', [[AGENT_TYPING]] indicated that the "type" internal animation is playing, it would not be set if the user disabled [[Debug Settings|PlayTypingAnim]]. '''On server 1.42 and up''', it reflects [[ChatFromViewer|typing start/stop messages]] from the client and does not depend on the  animation. If the old behavior is desired, use [[llGetAnimationList]] and look for {{NoWrap|{{String|c541c47f-e0c0-058b-ad1a-d6ae3a4584d9}}}} — {{Jira|SVC-787}}
*[[AGENT_ALWAYS_RUN]]{{!}}[[AGENT_WALKING]] indicates that the user requested to run using standard viewer controls. Use [[llGetAnimation]] to also detect running caused by physics.
* <code>[[AGENT_ALWAYS_RUN]] {{!}} [[AGENT_WALKING]]</code> indicates that the user requested to run using standard viewer controls. Use [[llGetAnimation]] to also detect running caused by physics.
*This function does not return reliable information immediately after a border crossing. Use [[llGetAnimation]] instead, if you can. {{Jira|SVC-3177}}
* This function does not return reliable information immediately after a border crossing. Use [[llGetAnimation]] instead, if you can. &mdash; {{Jira|SVC-3177}}
* [[AGENT_AUTOMATED]] may unexpectedly be enabled, see [[AGENT_AUTOMATED|its caveats]] for more detail.
|constants=
|constants=
{{{!}}class="wikitable sortable collapsible" {{Prettytable|style=margin-top:0;}}
{{LSL Constants/llGetAgentInfo|table=*}}
{{!}}-{{Hl2}}
! Constant
! title="Value" {{!}} {{HoverText|Val|Value}}
!class="unsortable"{{!}} Returned if agent...
{{!}}-
{{!}}{{LSL Const|AGENT_ALWAYS_RUN|integer|hex=0x1000|4096|c=has running ({{String|Always Run}}) enabled, or is using tap-tap-hold}}
{{!}}{{#var:value}}
{{!}}{{#var:comment}}
{{!}}-
{{!}}{{LSL Const|AGENT_ATTACHMENTS|integer|hex=0x0002|2|c=has attachments}}
{{!}}{{#var:value}}
{{!}}{{#var:comment}}
{{!}}-
{{!}}{{LSL Const|AGENT_AWAY|integer|hex=0x0040|64|c=is in {{String|away}} mode}}
{{!}}{{#var:value}}
{{!}}{{#var:comment}}
{{!}}-
{{!}}{{LSL Const|AGENT_BUSY|integer|hex=0x0800|2048|c=is in {{String|busy}} mode}}
{{!}}{{#var:value}}
{{!}}{{#var:comment}}
{{!}}-
{{!}}{{LSL Const|AGENT_CROUCHING|integer|hex=0x0400|1024|c=is crouching}}
{{!}}{{#var:value}}
{{!}}{{#var:comment}}
{{!}}-
{{!}}{{LSL Const|AGENT_FLYING|integer|hex=0x0001|1|c=is flying or hovering}}
{{!}}{{#var:value}}
{{!}}{{#var:comment}}
{{!}}-
{{!}}{{LSL Const|AGENT_IN_AIR|integer|hex=0x0100|256|c=is in the air (jumping, flying or falling)}}
{{!}}{{#var:value}}
{{!}}{{#var:comment}}
{{!}}-
{{!}}{{LSL Const|AGENT_MOUSELOOK|integer|hex=0x0008|8|c=is in mouselook}}
{{!}}{{#var:value}}
{{!}}{{#var:comment}}
{{!}}-
{{!}}{{LSL Const|AGENT_ON_OBJECT|integer|hex=0x0020|32|c=is sitting on an object}}
{{!}}{{#var:value}}
{{!}}{{#var:comment}}
{{!}}-
{{!}}{{LSL Const|AGENT_SCRIPTED|integer|hex=0x0004|4|c=has scripted attachments}}
{{!}}{{#var:value}}
{{!}}{{#var:comment}}
{{!}}-
{{!}}{{LSL Const|AGENT_SITTING|integer|hex=0x0010|16|c=is sitting}}
{{!}}{{#var:value}}
{{!}}{{#var:comment}}
{{!}}-
{{!}}{{LSL Const|AGENT_TYPING|integer|hex=0x0200|512|c=is typing}}
{{!}}{{#var:value}}
{{!}}{{#var:comment}}
{{!}}-
{{!}}{{LSL Const|AGENT_WALKING|integer|hex=0x0080|128|c=is walking, running or crouch walking}}
{{!}}{{#var:value}}
{{!}}{{#var:comment}}
{{!}}}
|examples=
|examples=
<lsl>
<syntaxhighlight lang="lsl2">
default
default
{
{
Line 83: Line 29:
         else
         else
             out += "The agent is not flying.\n";
             out += "The agent is not flying.\n";
       
         if(buf & AGENT_ATTACHMENTS)
         if(buf & AGENT_ATTACHMENTS)
         {
         {
Line 93: Line 39:
         else
         else
             out += "The agent does not have attachments.\n";
             out += "The agent does not have attachments.\n";
       
         if(buf & AGENT_MOUSELOOK)
         if(buf & AGENT_MOUSELOOK)
             out += "the agent is in mouselook.";
             out += "the agent is in mouselook.";
Line 101: Line 47:
     }
     }
}
}
</lsl>
</syntaxhighlight>


== How to build a script whit GetAgentInfo and sensor ==
<lsl>
//The stair sound script. Make a sculpted oe prim stair make sound when an avatar go up on down on It.
//MathieuBC Noel scripter and freebie maker. Don't erase that part when you use this script
key    id  ; 
default
{
    state_entry()
    {
       
    }
    collision_start(integer total_number)  //It's write colision start to notofy the computer that     
                                            //the next command line are going to work when the       
                                            //object detect an colision.
                                                 
    {   
        if (AGENT)                          //The computer star to read the command line when It's
                                            //an avatar colide on this.
          {
          llGetAgentInfo( id );            //Agent key is get by the object.
         
          llCollisionFilter("", id, TRUE);  //You have an colision only whit an agant whit the key                 
                                            //taken by the object.
         
          llSensorRepeat( "", id, AGENT, 3, PI,.7 ); //The sensor is sctivate each .7 second
           
            }
          else
            { 
              state off ;                    //If It's not an AGENT colision the computer must use   
                                              //the state off command line well below in the script
                                              //sheet.
             
              }
                }
              collision_end(integer total_number)
    {   
          llSensorRemove();                    //When the object did not detect an colision, the
                                                //sensor is remove
            }
           
           
           
            sensor(integer  total_number)      //This is the sensor action when It's activate whit
                                                //the above command line in the begin of this sheet.
    {
             
       
        if(AGENT_WALKING)                      //If the sensor detect in his radius an Agent
                                                //walking and running please dothe command line
                                                //below.
           
            llPlaySound("steps_on_wooden_stairs", 1.0);  //Play the sound name I put in the
                                                        //inventory object. You can also copy and 
                                                        //past the UUID of the soung between the two
                                                        //" .
       
        else                                            //Otherwise (else), if the agent do nothing
                                                        //read orther command line.
           
            llStopSound();                              //Stop sound
       
}
          land_collision_start(vector pos)              //If the object have an land colision follow
                                                        //the lines below.
   
{      llStopSound();                       
        llSensorRemove();                                //Remove the repeat sensor.
       
}
        }
       
      state off                                        //This is the state off apear in the beginig 
                                                        //of the script.                                 
{
    state_entry()
    {
       
    llStopSound();                                      //Stop sound                 
    llCollisionFilter("", id, FALSE);                    //Stop the filtering of collision identity 
                                                        //and UIID detection to choose to have and 
                                                        //colision whit It.
   
state default ;                                              //Retun to the begening of the script                                               
   
}
   
    }
</lsl>
|helpers
|helpers
|also_functions=
|also_functions=
Line 210: Line 59:
|also_articles
|also_articles
|notes=This is not a good way of testing if an avatar is in the region, use [[llGetAgentSize]] instead.
|notes=This is not a good way of testing if an avatar is in the region, use [[llGetAgentSize]] instead.
|history={{LSL Added|0.4.0|remote=http://secondlife.wikia.com/wiki/Version_0.4.0#Scripting}} along with these flags [[AGENT_FLYING]], [[AGENT_ATTACHMENTS]], & [[AGENT_SCRIPTED]].
*[[AGENT_AUTOPILOT]] was added in {{SVN|2900|rev=136439|trunk=*|ser=1.33.0|anchor=file21}}
|haiku={{Haiku|Information search:|The avatar was revealed,|Mystery solved.}}
|cat1=Avatar
|cat1=Avatar
|cat2
|cat2

Latest revision as of 08:03, 7 February 2024

Summary

Function: integer llGetAgentInfo( key id );
0.0 Forced Delay
10.0 Energy

Returns a bit field (an integer) containing the agent information about id.

• key id avatar UUID that is in the same region

Constant Val Returned if agent...
AGENT_ALWAYS_RUN 0x1000 has running ("Always Run") enabled, or is using tap-tap-hold
AGENT_ATTACHMENTS 0x0002 has attachments
AGENT_AUTOMATED 0x4000 is marked as a scripted agent/bot
AGENT_AUTOPILOT 0x2000 is in "autopilot" mode
AGENT_AWAY 0x0040 is in "away" mode
AGENT_BUSY 0x0800 is in "busy" mode
AGENT_CROUCHING 0x0400 is crouching
AGENT_FLYING 0x0001 is flying or hovering
AGENT_IN_AIR 0x0100 is in the air (jumping, flying or falling)
AGENT_MOUSELOOK 0x0008 is in mouselook
AGENT_ON_OBJECT 0x0020 is sitting on an object (and linked to it)
AGENT_SCRIPTED 0x0004 has scripted attachments
AGENT_SITTING 0x0010 is sitting[1]
AGENT_TYPING 0x0200 is typing
AGENT_WALKING 0x0080 is walking, running or crouch walking

Caveats

Examples

default
{
    touch_start(integer buf)
    {
        buf = llGetAgentInfo(llDetectedKey(0));
        string out;
        if(buf & AGENT_FLYING)
            out += "The agent is flying.\n";
        else
            out += "The agent is not flying.\n";
 
        if(buf & AGENT_ATTACHMENTS)
        {
            if(buf & AGENT_SCRIPTED)
                out += "The agent has scripted attachments.\n";
            else
                out += "The agent's attachments are unscripted.\n";
        }
        else
            out += "The agent does not have attachments.\n";
 
        if(buf & AGENT_MOUSELOOK)
            out += "the agent is in mouselook.";
        else
            out += "the agent is in normal camera mode.";
        llWhisper(0, out);
    }
}

Notes

This is not a good way of testing if an avatar is in the region, use llGetAgentSize instead.

See Also

Deep Notes

History

Tests

•  llGetAgentInfo_Test

Footnotes

  1. ^ "Sit down" on the avatar context menu allows ground sits anywhere: atop the terrain, on objects or even in the air, so it is possible to sit "on" an object without linking.
  2. ^ Early release notes were not very accurate or thorough, they sometimes included information about features added in previous releases or failed to include information about features added in that release.

Signature

function integer llGetAgentInfo( key id );

Haiku

Information search:
The avatar was revealed,
Mystery solved.