# llGetInventoryType

*LSL function*

```lsl
integer integer llGetInventoryType(string item);
```

- `string item`: Name of the item in the prim's inventory.

- Returns: `integer`
- Energy: 10

If `name` does not exist, [INVENTORY_NONE](/constants/INVENTORY_NONE/) is returned (no errors or messages are generated), making this function ideal for testing the existence of a certain item in [inventory](https://wiki.secondlife.com/wiki/inventory).

Returns an [integer](https://wiki.secondlife.com/wiki/integer) that is the type of the inventory item `name`

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

## Specification

<table>
	<tr>
		<td>

			<table>
				<tr>
					<th colspan="2">**Flag**</th>
					<th>**Inventory Type**</th>
				</tr>
				<tr>
					<td>[INVENTORY_NONE](/constants/INVENTORY_NONE/)</td>
					<td rowspan="2">-1</td>
					<td>Item does not exist.</td>
				</tr>
				<tr>
					<td>[INVENTORY_ALL](/constants/INVENTORY_ALL/)</td>
					<td>Any inventory type.</td>
				</tr>
				<tr>
					<td>[INVENTORY_TEXTURE](/constants/INVENTORY_TEXTURE/)</td>
					<td>0</td>
					<td>[texture](https://wiki.secondlife.com/wiki/texture)</td>
				</tr>
				<tr>
					<td>[INVENTORY_SOUND](/constants/INVENTORY_SOUND/)</td>
					<td>1</td>
					<td>[sound](https://wiki.secondlife.com/wiki/sound)</td>
				</tr>
				<tr>
					<td>[INVENTORY_LANDMARK](/constants/INVENTORY_LANDMARK/)</td>
					<td>3</td>
					<td>[landmark](https://wiki.secondlife.com/wiki/landmark)</td>
				</tr>
				<tr>
					<td>[INVENTORY_CLOTHING](/constants/INVENTORY_CLOTHING/)</td>
					<td>5</td>
					<td>[clothing](https://wiki.secondlife.com/wiki/clothing)</td>
				</tr>
				<tr>
					<td>[INVENTORY_OBJECT](/constants/INVENTORY_OBJECT/)</td>
					<td>6</td>
					<td>[object](https://wiki.secondlife.com/wiki/object)</td>
				</tr>
			</table>

		</td>
		<td>

			<table>
				<tr>
					<th colspan="2">**Flag**</th>
					<th>**Inventory Type**</th>
				</tr>
				<tr>
					<td>[INVENTORY_NOTECARD](/constants/INVENTORY_NOTECARD/)</td>
					<td>7</td>
					<td>[notecard](https://wiki.secondlife.com/wiki/notecard)</td>
				</tr>
				<tr>
					<td>[INVENTORY_SCRIPT](/constants/INVENTORY_SCRIPT/)</td>
					<td>10</td>
					<td>[script](https://wiki.secondlife.com/wiki/Script)</td>
				</tr>
				<tr>
					<td>[INVENTORY_BODYPART](/constants/INVENTORY_BODYPART/)</td>
					<td>13</td>
					<td>[body part](https://wiki.secondlife.com/wiki/Body_part)</td>
				</tr>
				<tr>
					<td>[INVENTORY_ANIMATION](/constants/INVENTORY_ANIMATION/)</td>
					<td>20</td>
					<td>[animation](https://wiki.secondlife.com/wiki/Animation)</td>
				</tr>
				<tr>
					<td>[INVENTORY_GESTURE](/constants/INVENTORY_GESTURE/)</td>
					<td>21</td>
					<td>[gesture](https://wiki.secondlife.com/wiki/gesture)</td>
				</tr>
				<tr>
					<td>[INVENTORY_SETTING](/constants/INVENTORY_SETTING/)</td>
					<td>56</td>
					<td>[setting](https://wiki.secondlife.com/wiki/Environmental_Enhancement_Project)</td>
				</tr>
				<tr>
					<td>[INVENTORY_MATERIAL](/constants/INVENTORY_MATERIAL/)</td>
					<td>57</td>
					<td>[material](https://wiki.secondlife.com/wiki/PBR_Materials)</td>
				</tr>
			</table>

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

## Examples

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

```lsl collapse={1-47, 53-59}
string get_type_info(integer inputInteger)
{
    if (inputInteger == INVENTORY_TEXTURE)
        return "INVENTORY_TEXTURE";

    else if (inputInteger == INVENTORY_SOUND)
        return "INVENTORY_SOUND";

    else if (inputInteger == INVENTORY_LANDMARK)
        return "INVENTORY_LANDMARK";

    else if (inputInteger == INVENTORY_CLOTHING)
        return "INVENTORY_CLOTHING";

    else if (inputInteger == INVENTORY_OBJECT)
        return "INVENTORY_OBJECT";

    else if (inputInteger == INVENTORY_NOTECARD)
        return "INVENTORY_NOTECARD";

    else if (inputInteger == INVENTORY_SCRIPT)
        return "INVENTORY_SCRIPT";

    else if (inputInteger == INVENTORY_BODYPART)
        return "INVENTORY_BODYPART";

    else if (inputInteger == INVENTORY_ANIMATION)
        return "INVENTORY_ANIMATION";

    else if (inputInteger == INVENTORY_GESTURE)
        return "INVENTORY_GESTURE";

    else if (inputInteger == INVENTORY_SETTING)
        return "INVENTORY_SETTING";

    else
        return "inventory type unknown";
}

default
{
    touch_start(integer num_detected)
    {
        integer totalItems = llGetInventoryNumber(INVENTORY_ALL);

        integer index;
        while (index < totalItems)
        {
            string itemName = llGetInventoryName(INVENTORY_ALL, index);
            integer type = llGetInventoryType(itemName);

            // PUBLIC_CHANNEL has the integer value 0
            llSay(PUBLIC_CHANNEL,
                "'" + itemName + "' (" + get_type_info(type) + ")");

            ++index;
        }
    }
}
```

</details>

## Helper functions

```lsl collapse={6-22}
string InventoryName(string name, integer type)
{ // finds an item in a case insensitive fashion of the given type and returns its true name.
    integer a = llGetInventoryType(name);
    if(!~a) // a == INVENTORY_NONE
    { // it should be noted that INVENTORY_NONE == INVENTORY_ALL == -1; which is why '!~a' works.
        string lc_name = llToLower(name);
        a = llGetInventoryNumber(type);
        while(a)
        { // (a = ~-a) is equivalent to --a, but runs faster.
            if(llToLower(name = llGetInventoryName(type, a = ~-a)) == lc_name)
            { // we found a match ^_^
                return name;
            }
        }
    }
    else if((a == type) ^ (!~type)) // return name, as long as a == type or type == INVENTORY_ALL
    { // we already know that a != INVENTORY_NONE, but just in case we use xor instead of or.
        return name;
    }
    return ""; // no match ~_~
}

integer InventoryExists(string name, integer type)
{ // only included to show how this type of check could be done if the value of 'type' is not constant and could be INVENTORY_ALL.
    return (llGetInventoryType(name) == type) ^ (!~type);
} // Since INVENTORY_ALL == INVENTORY_NONE, the extra part on the end is required to invert the result.
```

## Tests

- [llGetInventoryType_Test](https://wiki.secondlife.com/wiki/llGetInventoryType_Test)

## See also

### Functions

- [llGetInventoryAcquireTime](/functions/llGetInventoryAcquireTime/) — Returns the time the item was added to the prim's inventory
- [llGetInventoryName](/functions/llGetInventoryName/) — Returns the inventory item's name
- [llGetInventoryNumber](/functions/llGetInventoryNumber/) — Returns the number of items of a specific type in inventory
- [llGetInventoryCreator](/functions/llGetInventoryCreator/) — Returns the inventory item's creator
- [llGetInventoryPermMask](/functions/llGetInventoryPermMask/) — Returns the inventory item's permissions
- [llGetInventoryKey](/functions/llGetInventoryKey/) — Returns the inventory item's [UUID](https://wiki.secondlife.com/wiki/UUID) (if full perm)

---

*Source: [LlGetInventoryType](https://wiki.secondlife.com/wiki/LlGetInventoryType) on the Second Life Wiki. Content from the Second Life Wiki articles LlGetInventoryType (revision 1218327, 2025-06-05) and Template:LSL Constants Inventory (revision 1213767, 2023-03-24), CC BY-SA 3.0.*

---

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