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

LSL Wiki : sensor

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl836.us.archive.org
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 http://jira.secondlife.com/browse/SVC-1746 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:

Example:
default
{
    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
Comments [Hide comments/form]
It seems to me that the integer passed to the sensor event numbers the detected objects starting with 0, not 1. Can others confirm this?
-- ArbusFahid (2005-06-13 20:44:52)
This page's ACLs are messed up... And I don't believe BinoArbuckle is here anymore. Help!
-- KeknehvPsaltery (2005-07-13 14:22:33)
Yup, just like list indexes, the llDetected function integers are 0 to parameter - 1, where parameter is the integer passed to the touch*, collision* or sensor events.
-- ChristopherOmega (2005-07-14 15:15:36)
At the moment, in 1.7, it seems that sensors overlapping sim bounderies are NOT working correctly - they only sense objects intermittently, or not at all.
-- ZodiakosAbsolute (2005-11-08 19:04:42)
I dont think its possible, but could a sensor detected prims within the object sensoring?
-- KairaOverdrive (2005-11-10 13:25:14)
Why would you do that? It'd be easier -- both script-wise and on the server -- to use link messages.
-- DolusNaumova (2005-12-10 10:45:57)
Kaira, See above Q&A.
-- StPsaltery (2006-01-09 16:21:40)
It says "sorted by target distance", but as far as I can tell, currently this isn't true. Bug?
-- DaleGlass (2006-08-07 18:39:47)
Dale: Sensors DO record by closest at this time.

default
{
    state_entry()
    {
        llSetObjectName("test");
        llSensor("Object", NULL_KEY, PASSIVE, 96, PI*2);
    }

    sensor(integer a)
    {
        integer i;
        for(i=0;i<a;i++)
        {
            llOwnerSay(llDetectedName(i) + "(" + (string)llVecDist(llGetPos(), llDetectedPos(i)) + "m)");
        }
    }
}

This returned:
[9:25] test: Object(2.445294m)
[9:25] test: Object(2.869154m)
[9:25] test: Object(2.869968m)
Etc.... Continuing at large distances away.
-- BirdRaven (2006-08-08 09:29:54)
Ok, here's the modified script. I changed it to detect agents instead, and warn if the distance is wrong. Notice how I save the value of llGetPos to make sure I can't screw it up by moving around. It still manages to be out of order sometimes though (not always), and seems to have something to do with movement, although I'm not sure if mine or the agent's.

default
{
    state_entry()
    {
        llSetObjectName("test");
        llSensorRepeat("", NULL_KEY, AGENT, 96, PI*2,5.0);
    }

    sensor(integer a)
    {
        integer i;
        vector my_pos = llGetPos();
        float prev_dist = 0.0;
        float dist;
        
        for(i=0;i<a;i++) {
            dist = llVecDist(my_pos, llDetectedPos(i));
            if ( dist < prev_dist ) {
                llOwnerSay("!!!!! BAD !!!!!!");
            }
            llOwnerSay(llDetectedName(i) + "(" + (string)dist+ "m)");
            prev_dist = dist;
        }
        llOwnerSay("=== end ===");
    }
}

Here's the output:
[11:59] test: Silverfang Mason(7.435206m)
[11:59] test: Cats Mousehold(9.651114m)
[11:59] test: Very Meek(11.119104m)
[11:59] test: Somewhat Meek(12.123158m)
[11:59] test: Tengu Yamabushi(13.053590m)
[11:59] test: Rather Meek(13.464032m)
[11:59] test: Not Meek(13.738073m)
[11:59] test: !!!!! BAD !!!!!!
[11:59] test: Kamatz Kuhr(13.328423m)
[11:59] test: Markus Austin(13.999367m)
[11:59] test: Dougal Jacobs(14.298283m)
[11:59] test: Akurei Sieyes(15.067903m)
[11:59] test:

end

-- DaleGlass (2006-08-08 12:09:38)
Attach a comment to this page: