llGetAgentInfo

From Second Life Wiki
Jump to navigation Jump to search

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

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

} </lsl> <lsl> // A simple typing override example. // Modified the example-LSL of llGetAnimation to make it work with llGetAgentInfo. // Also included an easy way to hide and show the whole object depending on current typing state. // For example: Show a keyboard under avatars hands when avatar types.

// User functions doStuff(){

   llStartAnimation("run");
   llSetAlpha(1,ALL_SIDES);

}

stopStuff(){

   llStopAnimation("run");
   llSetAlpha(0,ALL_SIDES);

}

key gOwner; // the wearer's key integer gLastAnimation; // last llGetAnimation value seen

// Event handlers default {

   state_entry() {
       string id=llGetOwner();
       // in case the script was reset while already attached
       if (llGetAttached() != 0) {
           if (id == NULL_KEY) { // detaching
               llSetTimerEvent(0.0); // stop the timer
           }
           else { // attached, or reset while worn
               llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION);
               gOwner = id;
           }
       }
   }

   attach(key id) {
       llResetScript();
   }

   run_time_permissions(integer perm) {
       if (perm & PERMISSION_TRIGGER_ANIMATION) {
           llSetTimerEvent(0.25); // start polling
       }
   }

   timer() {
       integer newAnimation = llGetAgentInfo(gOwner);

       if (gLastAnimation != newAnimation) { // any change?
           if(newAnimation & AGENT_TYPING){
               doStuff();
           }
           else if (gLastAnimation !=(newAnimation & AGENT_TYPING))  {
               stopStuff();
           }
           gLastAnimation = newAnimation; // store away for  next time
       }
   }

}

</lsl>

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