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

LSL Wiki : llSensor

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are crawl423.us.archive.org
llSensor(string name, key id, integer type, float range, float arc)

Performs a single sensor scan for name and id with type (AGENT, ACTIVE, PASSIVE, and/or SCRIPTED) within range meters and arc radians of forward vector (along x-axis). PI radians will search in all directions.

name and id need no filter. If name is a null string (i.e. ""), llSensor() will look for objects with any name. If id is the NULL_KEY, then llSensor() will look for objects with any id. The limit of range is 96m. Values greater than 96m will be accepted but will be treated as 96m. Note that a range of 0.0 does perform a scan.

Compare with llSensorRepeat, which allows a recurring sensor scan.

Raises the sensor event when it finds a match, and no_sensor when it finds none; see sensor for an example.

Constants for type:
Constant Value Searches for
AGENT 1 agents (users)
ACTIVE 2 physical objects that are moving or objects containing an active[1] script
PASSIVE 4 non-scripted or script is inactive[2] AND non-physical or, if physical, not moving
SCRIPTED 8 objects containing an active[3] script
[1] Active: the script is running and currently doing something. A basic default script that is running may not be active but a script that has a command monitoring, like with llListen, will always be active. "Active" means more sim resources are being used.
[2] Inactive: the script is running and awaiting an event and isn't doing any monitoring (like llListen). Very little sim resources are being used.
[3] Running scripts may be active or inactive (or, to use SL lingo, "active" or "passive").

Notes


Combining SCRIPTED and Other Flags

Combining the SCRIPTED flag with others can lead to somewhat unintuitive results (this is because AGENT, PASSIVE and ACTIVE behave inclusively. SCRIPTED is not inclusive and will exclude non-scripted targets, like avatars, from the detected set):


Detection Cones (Arc)

If arc is x radians, the sensor will look for x radians around the object's forward vector (which is the object's local X axis, positive direction), so the actual sweep of the search is 2 * x radians, and thus PI radians will search all around the object.

In SL terms, the sensor sweep area is a dimpled sphere, with the range defined by the sphere's radius and the arc by the dimple itself.

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.

Sensor Visualisation

This one has arc = PI / 4 and thus scans a radius of 45 degree around the x-axis:


video (MPEG, 630KB) of it rotating

For arc = PI_BY_TWO (90 degrees around the x-axis, or a half sphere--hemisphere):

And for arc = PI (180 degrees around the x-axis, which means a sphere):


Q: Can I use sensors to detect attachments?
A: No, but you can use llGetAgentInfo to determine whether or not an avatar has attachments, and whether or not they're scripted, though not how many attachments they have, where they're attached, nor what they are.
Q: How can I use a sphere prim to determine sensor radians?
A: Using just the Begin dimple, keeping the end 1.0, the math would be: radians = PI - (PI * dimple);

This article wasn't helpful for you? Maybe the related article at the LSL Portal is able to bring enlightenment.

Functions | Sensors
Comments [Hide comments/form]
Images created with the really cool POV-Ray.
-- EzharFairlight (2004-03-15 11:42:33)
I've tested the value 3 in this function and it does not work as documented by whomever added it. These are bitwise operators. As such the value of ' 3 ' is the same as using the Constants AGENT (1) and ACTIVE (2).
-- ObsidianStormwind (2005-07-25 17:56:15)
I don't understand why the reference to '3' being for physical objects only was put back - I've never been able to make that work. And Obsidian is right, if these are bits, then 3 is AGENT | ACTIVE.
-- JillianCallahan (2005-07-25 18:37:50)
It seems that AGENT | SCRIPTED only detects scripted objects, and not agents.
-- SchitsoMonkey (2005-08-26 19:37:02)
I hope I didn't just piss off the wiki gods [or any of you:)] by shuffling the page around, but frankly, this page was just a tad unorganized.
-- IoneLameth (2005-11-13 09:22:50)
Why the change from prim to object, BlindWanderer? Unless I'm missing something, children can only ever be prims, right? Isn't it more useful to be be more specific?
-- IoneLameth (2005-11-14 16:37:33)
I changed some of the definitions of active and passive. My experiments show that any script consumes sim resources, even inactive. Drop a few thousand copies of Hello Avatar into a prim and watch the sim go down in flames.
-- GigsTaggart (2006-07-01 19:46:11)
I think the note:

After detecting a PASSIVE, ACTIVE, and/or SCRIPTED object, llDetectedType may be used to check the ACTIVE flag (physical) and the PASSIVE flag (non-physical, even if the object contains an active script). The SCRIPTED flag always seems to only detect/apply to active scripts. So it seems llSensor and llDetectedType use the PASSIVE and ACTIVE flags differently. See also ObjectType for more info about types of objects to detect.

is confusing and possibly wrong. After several readings and a bit of experimenting I think perhaps it should be reworded to something like:

llDetectedType and llSensor use the flags differently. In particular llSensor uses ACTIVE to detect any active script (which in the current system seems to be any running script) or any physical object, or both whilst llDetectedType uses ACTIVE solely for physical objects, PASSIVE for non-physical objects.
-- EloisePasteur (2006-10-15 05:39:02)
For some weird reason, sometimes my Sensor detects people that are more than an entire sim away. I put in a safeguard against that, since it's utterly useless information, but there should probably be a little note in here about that.
-- VirusCollector (2006-11-27 15:16:24)
Experiment suggests that setting "Type" to zero does not do any sensor scan -- neither sensor nor no_sensor are triggered.
-- KimbeauSurveryor (2006-12-02 17:01:48)
It seems easier to visualize a sensor cone by setting a sphere dimple *begin* to 0.0, and the *end* to the desired size. The equation for sensor arc would then be arc = (PI * dimpleEnd) and the resulting sphere will have a sensor pattern that has the same direction and pattern as shown by the cone.
-- DahliaTrimble (2007-07-27 15:58:33)
Its wonderful, Nice!
-- host-12-5-74-139.etcable.net (2007-09-11 01:24:38)
I don't uderstand how is possible set sensor to report only object that are placed backward the avatar .... i have try to set a negative arc but with not goor results ... anyone have a suggest?

thank u
-- adsl-ull-52-228.46-151.net24.it (2007-10-17 00:49:39)
Attach a comment to this page: