Difference between revisions of "LlGetAgentInfo"

From Second Life Wiki
Jump to: navigation, search
m (I had a script that I build mysel A to Z whit commants insides)
Line 101: Line 101:
 
     }
 
     }
 
}
 
}
 +
</lsl>
 +
 +
 +
== 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>
 
</lsl>
 
|helpers
 
|helpers

Revision as of 10:22, 27 August 2009

Summary

Function: integer llGetAgentInfo( key id );

Returns an integer bitfield 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_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
AGENT_SCRIPTED 0x0004 has scripted attachments
AGENT_SITTING 0x0010 is sitting
AGENT_TYPING 0x0200 is typing
AGENT_WALKING 0x0080 is walking, running or crouch walking

Caveats

Important Issues

~ All Issues ~ Search JIRA for related Bugs
   llGetAgentInfo() returns unreliable info after a sim border crossing

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>


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>

Notes

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

See Also

Deep Notes

All Issues

~ Search JIRA for related Issues
   llGetAgentInfo() returns unreliable info after a sim border crossing

Tests

•  llGetAgentInfo_Test

Signature

function integer llGetAgentInfo( key id );