User:Opensource Obscure/Agent Sensor

From Second Life Wiki
Jump to navigation Jump to search

<lsl> float radius = 96.0;

default {

   state_entry()
   {
       llOwnerSay("Hello, Avatar!");
   }


   touch_start(integer total_number)
   {
       llSensor("", NULL_KEY, AGENT, radius, PI);
   }


   sensor(integer total_number) // total_number is the number of .. detected.
   {
       llOwnerSay((string)total_number + " avatars detected" );
       // The following 'for' loop runs through all detected .. and says "Hello ..",
       // where ".." is the name of the current detected ..
       integer i;
       for (i = 0; i < total_number; i++)
       {
           llOwnerSay(llDetectedName(i));
           llOwnerSay(llDetectedKey(i));
           llOwnerSay("* * * * * * * ");
       }
   }


   // if nothing is within 10 meters, say so.
   no_sensor() 
   {
       llOwnerSay("noone around.");
   }


} </lsl>