Difference between revisions of "Sensor"

From Second Life Wiki
Jump to navigation Jump to search
m (added an example)
(<lsl> example)
Line 9: Line 9:
|examples=Names people who are near an object.
|examples=Names people who are near an object.


<pre>
<lsl>float range = 3.0; //  metres
float range = 3.0; //  metres
float interval = 5.0; // seconds
float interval = 5.0; // seconds


Line 38: Line 37:
         llWhisper(0, "Nobody is near me at present.");
         llWhisper(0, "Nobody is near me at present.");
     }
     }
}
}</lsl>
</pre>
|helpers
|helpers
|also_header
|also_header

Revision as of 13:33, 16 February 2008

Description

Event: sensor( integer num_detected ){ ; }

Result of the llSensor library function call.

• integer num_detected

The results are ordered from nearest to furtherest.

Caveats


Examples

Names people who are near an object.

<lsl>float range = 3.0; // metres float interval = 5.0; // seconds

default {

   state_entry()
   {
        llSensorRepeat("", "", AGENT, range, TWO_PI, interval); // 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): ";
       integer i;
       msg += llDetectedName(0);
       for (i = 1; i < numberDetected; i++)
       {
           msg += ", ";
           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 );