Difference between revisions of "Sensor"

From Second Life Wiki
Jump to navigation Jump to search
m (sensor in hud doesn't detect "me")
m
Line 8: Line 8:
|spec
|spec
|caveats=*[[Linden]]s in administrative mode cannot be sensed by sensors in the same region as the Linden.
|caveats=*[[Linden]]s in administrative mode cannot be sensed by sensors in the same region as the Linden.
*A sensor running in a HUD will not detect the avatar wearing it.
*A sensor running in an attachment will not detect the avatar wearing it.
|examples=
|examples=
<lsl>float range = 10.0; //  metres
<lsl>float range = 10.0; //  meters
   
   
default
default
Line 19: Line 19:
         // look for avatars (i.e. not moving objects) on all sides of the object
         // look for avatars (i.e. not moving objects) on all sides of the object
     }
     }
   
     sensor (integer numberDetected)
     sensor (integer numberDetected)
     {
     {
Line 30: Line 30:
         llWhisper(0, msg);
         llWhisper(0, msg);
     }
     }
   
     no_sensor()
     no_sensor()
     {
     {

Revision as of 10:24, 19 November 2008

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

  • Lindens in administrative mode cannot be sensed by sensors in the same region as the Linden.
  • A sensor running in an attachment will not detect the avatar wearing it.
All Issues ~ Search JIRA for related Bugs

Examples

<lsl>float range = 10.0; // meters

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