# llDetectedType

*LSL function*

```lsl
integer integer llDetectedType(integer number);
```

- `integer number`: Index of the detection information.

- Returns: `integer`
- Energy: 10

Returns an integer bitfield representing the types (AGENT, ACTIVE, PASSIVE, or SCRIPTED) of the detected object or avatar specified by number. Returns 0 if number is not a valid index.

Returns `zero` if **number** is not valid sensed object or avatar.

Returns an [integer](https://wiki.secondlife.com/wiki/integer) that is the types of the detected object or avatar.

```lsl title="How to use" frame="terminal"
integer result = llDetectedType(0);
```

## Specification

<table>
	<tr>
		<td>

			<table>
				<tr>
					<th colspan="2">**Flag Mask**</th>
					<th>**Description ([llDetectedType](/functions/llDetectedType/)())**</th>
					<th>**Description ([llSensor](/functions/llSensor/)() and [llSensorRepeat](/functions/llSensorRepeat/)() mask)**</th>
				</tr>
				<tr>
					<td>[AGENT_BY_LEGACY_NAME](/constants/AGENT_BY_LEGACY_NAME/)</td>
					<td>0x1</td>
					<td>Agents</td>
					<td>This is used to find agents by [legacy name](https://wiki.secondlife.com/wiki/Category:LSL_Avatar/Name).</td>
				</tr>
				<tr>
					<td>[AGENT](/constants/AGENT/)</td>
					<td>0x1</td>
					<td>Agents</td>
					<td>This is also used to find agents by [legacy name](https://wiki.secondlife.com/wiki/Category:LSL_Avatar/Name), and is functionally identical to [AGENT_BY_LEGACY_NAME](/constants/AGENT_BY_LEGACY_NAME/)</td>
				</tr>
				<tr>
					<td>[AGENT_BY_USERNAME](/constants/AGENT_BY_USERNAME/)</td>
					<td>0x10</td>
					<td>*Reserved*</td>
					<td>This is used to find agents by [username](https://wiki.secondlife.com/wiki/Category:LSL_Avatar/Name).</td>
				</tr>
				<tr>
					<td>[ACTIVE](/constants/ACTIVE/)</td>
					<td>0x2</td>
					<td>Physical tasks. (Physical objects & agents)</td>
					<td>Physical objects that are moving or objects containing an active script. Thus, it is using SL server resources now.</td>
				</tr>
				<tr>
					<td>[PASSIVE](/constants/PASSIVE/)</td>
					<td>0x4</td>
					<td>Non-physical objects.</td>
					<td>Non-scripted or script is inactive and non-physical or, if physical, not moving. Thus, it is not using SL server resources now.</td>
				</tr>
				<tr>
					<td>[SCRIPTED](/constants/SCRIPTED/)</td>
					<td>0x8</td>
					<td>Objects containing any active script.</td>
					<td>Objects that has any script, which is doing anything in simulator just now.</td>
				</tr>
				<tr>
					<td>[DAMAGEABLE](/constants/DAMAGEABLE/)</td>
					<td>0x20</td>
					<td>Objects & agents that are able to process damage.</td>
					<td>Filter for objects in world that have a script with [on_damage](/events/on_damage/) or a [final_damage](/events/final_damage/) event (able to process damage)</td>
				</tr>
			</table>

			| [llDetectedType](/functions/llDetectedType/)() | Scripted | Not Scripted | Agent Standing | Agent Sitting |
			| --- | --- | --- | --- | --- |
			| Physical Movement | [SCRIPTED](/constants/SCRIPTED/)) | 2 ([ACTIVE](/constants/ACTIVE/)) | [AGENT](/constants/AGENT/)) | [AGENT](/constants/AGENT/)) |
			| Non-Physical | [SCRIPTED](/constants/SCRIPTED/)) | 4 ([PASSIVE](/constants/PASSIVE/)) | 1 ([AGENT](/constants/AGENT/)) | [AGENT](/constants/AGENT/)) |

		</td>
	</tr>
</table>

## Examples

<details open>
<summary>Example 1</summary>

```lsl collapse={1-6, 12-18}
//--// Type & name of collision source //--//

default{
    collision_start( integer vIntCollided ){
        integer vBitType;
        string vStrType;
        do
        {
            vBitType = llDetectedType( --vIntCollided );
            if (vBitType & AGENT_BY_LEGACY_NAME)
                vStrType = "avatar";
            else
                vStrType = "object";
            llOwnerSay( "An " + vStrType + " named '" + llDetectedName( vIntCollided ) + "' collided with me" );
        }
        while (vIntCollided);
    }
}
```

</details>

---

*Source: [LlDetectedType](https://wiki.secondlife.com/wiki/LlDetectedType) on the Second Life Wiki. Content from the Second Life Wiki articles LlDetectedType (revision 1217716, 2024-12-05), Template:LSL Constants Sensor (revision 1217617, 2024-11-07), Template:HoverText (revision 379053, 2009-06-01) and Template:LSL Function/detected (revision 1168823, 2012-06-11), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/functions/llDetectedType/
