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

LSL Wiki : llSensor

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are
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").


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
There are 13 comments on this page. [Display comments/form]