Don't click here unless you want to be banned.

LSL Wiki : sensor

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are
sensor(integer num_detected)

This event is raised whenever objects matching the constraints of the llSensor or llSensorRepeat functions are detected. The number of detected objects is passed to the script in num_detected. Information on those objects may then be gathered via the llDetected* library functions.

If no matches are found, no_sensor will be raised instead.

The sensor() event handler will receive a maximum of 16 detected objects within 96m, sorted by target distance.

It seems that avatars in vehicles can be detected up by a sensor from very far distances. The most I've ever seen was over 1,000m away! -SchitsoMonkey
According to if your sensor range overlaps <0,0,0>, all sitting agents in the sim will be detected. That would explain it nicely. - RikaWatanabe
"If the center of a vehicle is within the range of the sensor, all agents seated on that vehicle are detected even if out of the range of the sensor. This can add considerably to the detection range." - CharonAllen

In the following example, clicking the object causes it to scan once for the presence of agents within a radius of 10m in all directions. If any agents are detected, the object whispers their names in order:

    touch_start(integer total_number)
        llSensor("", NULL_KEY, AGENT, 10, PI); // scan for agents/avatars within 10 metres

    sensor(integer total_number) // total_number is the number of avatars detected.
        llWhisper(0, (string)total_number + " avatars detected" );
        // The following 'for' loop runs through all detected avatars and says "Hello Jane Doe",
        // where "Jane Doe" is the name of the current detected avatar.
        integer i;
        for (i = 0; i < total_number; i++)
            llWhisper(0, "Hello " + llDetectedName(i));
    // if nobody is within 10 meters, say so.
    no_sensor() {
        llSay(0, "Nobody is around.");

Q: Do sensor areas overlapping simulator boundaries carry over into the other simulator(s)? Are they supposed to?
A: Not in all cases. As of 1.11 or so, llSensor does not detect across sim boundaries at all and llSensorRepeat is limited by only detecting across boundaries approximately every five seconds.

Q: Can a sensor detect child prims within the object that contains the sensor?
A: No. Sensors only detect the root prim in a linkset, and never the object containing the sensor itself. This is a good thing, as otherwise it would be possible to reverse-engineer linked objects and recreate them, completely negating asset permissions.
Likewise, sensors contained within attachments cannot be used to detect the agent to which the attachment is attached.

Q: Is there a way to just check whether an agent is within a sim?
A: Yes. Assuming you know the agent's key, you can use llKey2Name. No sensor is required. If you don't know the key.

Q: Is there a way to get a list of all agents within a sim?
A: No, not without many objects containing sensors and a fairly elaborate communications system. There isn't a way to just get a list.

Q: Where is the sensors origin in link sets?
A: A sensors point of origin in linked objects is from the prim calling the function. Not the root or the center of the linkset.

Q: How to detect more than 16 results in the area? Can i filter the results of 'first sensor' to find 16 different results with a 'second sensor'?
A: "It is possible if you use different objects with a sensor in it and place them at different spots. Let the objects communicate with a kind of chief-object or server, using llRegionSay( 'private-channel', "key detected agent"); for every agent detected. Let the 'server' make a list of all incomming keys comparing them with the keys in the list (so they dont occur twice or more times), then let the server say or display the key's or names of all agents in the list - Jody Palmer".

Events | Functions | Sensors
There are 10 comments on this page. [Display comments/form]