Sensor

From Second Life Wiki
Revision as of 10:39, 4 December 2007 by Udge Watanabe (talk | contribs) (added an example)
Jump to navigation Jump to search

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.

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.");
    }
}

See Also

Functions

•  llSensor
•  llSensorRepeat

Articles

•  Detected

Deep Notes

Signature

event void sensor( integer num_detected );