Difference between revisions of "Sensor"

From Second Life Wiki
Jump to navigation Jump to search
(i can understand why you removed the example but we need examples. Do not remove examples unless you replace it with a better one.)
m
Line 4: Line 4:
|event_desc=Results from a call to either [[llSensor]] or [[llSensorRepeat]].
|event_desc=Results from a call to either [[llSensor]] or [[llSensorRepeat]].
|event_footnote=The results are ordered from nearest to furthest.
|event_footnote=The results are ordered from nearest to furthest.
'''num_detected''' is never zero, the [[no_sensor]] event is triggered instead.
<br/>'''num_detected''' is never zero, the [[no_sensor]] event is triggered instead.
|constants
|constants
|spec
|spec

Revision as of 23:32, 27 March 2008

Description

Event: sensor( integer num_detected ){ ; }

Results from a call to either llSensor or llSensorRepeat.

• integer num_detected number of objects and avatars found

The results are ordered from nearest to furthest.
num_detected is never zero, the no_sensor event is triggered instead.

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