Sensor

From Second Life Wiki
Revision as of 17:25, 14 August 2008 by Stickman Ingmann (talk | contribs) (Added caveat: Lindens cannot be sensor()ed.)
Jump to navigation Jump to search

Description

Event: sensor( integer num_detected ){ ; }

Results from a call to either llSensor or llSensorRepeat.

• integer num_detected number of objects/avatars found

The results are ordered from nearest to furthest.
num_detected is always greater than zero, the no_sensor event is triggered if no objects/avatars were found.

Caveats


Examples

<lsl>float range = 10.0; // metres

default {

   touch_start(integer numberDetected)
   {
        llSensor("", "", AGENT, range, PI); // activates the sensor.
        // look for avatars (i.e. not moving objects) on all sides of the object
   }

   sensor (integer numberDetected)
   {
       string msg = "Detected " + (string)numberDetected + " avatar(s): " + llDetectedName(0);
       integer i = 0;
       while(numberDetected > ++i)//skips the first item which suits this application
       {
           msg += ", " + llDetectedName(i);
       }
       llWhisper(0, msg);
   }

   no_sensor()
   {
       llWhisper(0, "Nobody is near me at present.");
   }

}</lsl>

See Also

Functions

•  llSensor
•  llSensorRepeat

Articles

•  Detected

Deep Notes

Signature

event void sensor( integer num_detected );