# llGetInventoryName

*LSL function*

```lsl
string string llGetInventoryName(integer type, integer index);
```

- `integer type`: INVENTORY_* type constant of the item.
- `integer index`: Index of the item of that type.

- Returns: `string`
- Energy: 10

Inventory items are sorted in alphabetical order (not chronological order).

Returns a [string](https://wiki.secondlife.com/wiki/string) that is the name of the inventory item `number` of **type**. Returns an empty string if no item of the specified type is found in the prim's inventory (or there are less than or equal to `number` items of the type).

```lsl title="How to use" frame="terminal"
string result = llGetInventoryName(0, 0);
```

## 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>

##### Box Unpacker

```lsl collapse={1-10, 16-20}
// Give all prim contents to anyone touching this object,
// But don't give this script itself.

default
{
    touch_start(integer num_detected)
    {
        list    InventoryList;
        integer count = llGetInventoryNumber(INVENTORY_ALL);  // Count of all items in prim's contents
        string  ItemName;
        while (count--)
        {
            ItemName = llGetInventoryName(INVENTORY_ALL, count);
            if (ItemName != llGetScriptName() )
                InventoryList += ItemName;   // add all contents except this script, to a list
        }
        // Give all the items to the toucher, in a folder named as per this prim's name
        llGiveInventoryList(llDetectedKey(0), llGetObjectName(), InventoryList);
    }
}
```

</details>

## Notes

The maximum number of characters for an object inventory item is currently 63 characters.

## Tests

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

## See also

### Functions

- [llGetInventoryAcquireTime](/functions/llGetInventoryAcquireTime/) — Returns the time the item was added to the prim's inventory
- [llGetInventoryNumber](/functions/llGetInventoryNumber/) — Returns the number of items of a specific type in inventory
- [llGetInventoryType](/functions/llGetInventoryType/) — Tests to see if an inventory item exists and returns its type.
- [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: [LlGetInventoryName](https://wiki.secondlife.com/wiki/LlGetInventoryName) on the Second Life Wiki. Content from the Second Life Wiki articles LlGetInventoryName (revision 1213696, 2023-03-09), Template:LSL Constants Inventory (revision 1213767, 2023-03-24) and Template:LSL Function/negative index (revision 1200041, 2016-05-02), CC BY-SA 3.0.*

---

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