Difference between revisions of "LlGetInventoryName"
Jump to navigation
Jump to search
Kireji Haiku (talk | contribs) m (added LSL Tip) |
Omei Qunhua (talk | contribs) (Simplify the example while improving its functionality. Remove irrelevant "tip") |
||
Line 7: | Line 7: | ||
|func_footnote= | |func_footnote= | ||
Inventory items are sorted in alphabetical order (not chronological order). | Inventory items are sorted in alphabetical order (not chronological order). | ||
|func_desc | |func_desc | ||
|return_text=that is the name of the inventory item {{LSLP|number}} of {{LSLP|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 {{LSLP|number}} items of the type). | |return_text=that is the name of the inventory item {{LSLP|number}} of {{LSLP|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 {{LSLP|number}} items of the type). | ||
Line 15: | Line 14: | ||
|examples======Box Unpacker===== | |examples======Box Unpacker===== | ||
<lsl> | <lsl> | ||
// | // Give all prim contents to anyone touching this object, | ||
// But don't give this script itself. | |||
// | |||
default | default | ||
{ | { | ||
touch_start(integer num_detected) | touch_start(integer num_detected) | ||
{ | { | ||
list InventoryList; | |||
string | integer count = llGetInventoryNumber(INVENTORY_ALL); // Count of all items in prim's contents | ||
string ItemName; | |||
llGiveInventoryList( | 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); | |||
} | } | ||
} | } |
Revision as of 10:42, 7 January 2013
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: string llGetInventoryName( integer type, integer number );0.0 | Forced Delay |
10.0 | Energy |
Returns a 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).
• integer | type | – | INVENTORY_* flag | |
• integer | number | – | Beginning from 0 |
number does not support negative indexes. Inventory items are sorted in alphabetical order (not chronological order).
|
|
Caveats
- If number is out of bounds the script continues to execute without an error message.
Examples
Box Unpacker
<lsl> // 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); }
}
</lsl>Notes
The maximum number of characters for an object inventory item is currently 63 characters.
See Also
Functions
• | llGetInventoryNumber | – | Returns the number of items of a specific type in inventory | |
• | llGetInventoryType | – | Tests to see if an inventory item exists and returns its type. | |
• | llGetInventoryCreator | – | Returns the inventory item's creator | |
• | llGetInventoryPermMask | – | Returns the inventory item's permissions | |
• | llGetInventoryKey | – | Returns the inventory item's UUID (if full perm) |