Difference between revisions of "Sensor"

From Second Life Wiki
Jump to navigation Jump to search
m
Line 14: Line 14:
*on logout all avatars leave a Ghost for a few moments, this results in Failures in llDetected functions in sensor events.
*on logout all avatars leave a Ghost for a few moments, this results in Failures in llDetected functions in sensor events.
|examples=
|examples=
<lsl>float range = 10.0; // meters
<lsl>float range = 10.0;// Meters
   
   
default
default
{
{
     touch_start(integer numberDetected)
     touch_start(integer total_number)
     {
     {
         llSensor("", "", AGENT, range, PI); // activates the sensor.
         llSensor("", "", AGENT, range, PI); // *HACK: Activates the sensor.
         // look for avatars (i.e. not moving objects) on all sides of the object
         // *NOTE: Look for avatars (i.e. not moving objects) on all sides of the object
     }
     }
   
 
     sensor (integer numberDetected)
     sensor(integer num_detected)
     {
     {
         string msg = "Detected " + (string)numberDetected + " avatar(s): " + llDetectedName(0);
         string msg = "Detected " + (string)num_detected + " avatar(s): " + llDetectedName(0);
         integer i = 0;
         integer i = 0;
         while(numberDetected > ++i)//skips the first item which suits this application
         while(num_detected > ++i)// *TODO: Skips the first item which suits this application
         {
         {
             msg += ", " + llDetectedName(i);
             msg += ", " + llDetectedName(i);
Line 34: Line 34:
         llWhisper(0, msg);
         llWhisper(0, msg);
     }
     }
   
 
     no_sensor()
     no_sensor()
     {
     {

Revision as of 21:21, 19 February 2011

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.
  • Sensors placed in attachments will use the direction the avatar is facing as their forward vector. In mouselook, this means that it will be wherever the avatar is looking, while out of mouselook, this means whichever way the avatar is pointing. This does not include where the avatar's head is pointing, or what animation the avatar is doing, just the direction the avatar would move in if you walked forward. This is the case, regardless of where the object is attached.
  • A sensor running in an attachment will not detect the avatar wearing it.
  • A sensor will only return the first 16 objects/avatars found.
  • This event is not executed when nothing is detected, means, you never get the result 0 returned.
  • on logout all avatars leave a Ghost for a few moments, this results in Failures in llDetected functions in sensor events.
All Issues ~ Search JIRA for related Bugs

Examples

<lsl>float range = 10.0;// Meters

default {

   touch_start(integer total_number)
   {
        llSensor("", "", AGENT, range, PI); // *HACK: Activates the sensor.
        // *NOTE: Look for avatars (i.e. not moving objects) on all sides of the object
   }
   sensor(integer num_detected)
   {
       string msg = "Detected " + (string)num_detected + " avatar(s): " + llDetectedName(0);
       integer i = 0;
       while(num_detected > ++i)// *TODO: 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 );