OsGetInventoryItemKeys

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Created page with "{{osslfunc |threat_level=ignored |permissions=true |delay=0|function_syntax=list osGetInventoryItemKeys(integer type)<br> list osGetLinkInventoryItemKeys(integer linkNumber, i...")
 
m (Clarified GetInventoryKey/GetInventoryItemKey difference)
Line 84: Line 84:
 
|description=
 
|description=
 
Return a list of the items UUIDs by type (or INVENTORY_ALL) located in the host or child prim prim inventory.
 
Return a list of the items UUIDs by type (or INVENTORY_ALL) located in the host or child prim prim inventory.
 +
Note that unlike llGetInventoryKey, this function returns the item ID, not ID of its asset.
 
|additional_info=Added in 0.9.3.0
 
|additional_info=Added in 0.9.3.0
 
}}
 
}}

Revision as of 21:47, 18 March 2024

list osGetInventoryItemKeys(integer type)

list osGetLinkInventoryItemKeys(integer linkNumber, integer type)

Return a list of the items UUIDs by type (or INVENTORY_ALL) located in the host or child prim prim inventory.

Note that unlike llGetInventoryKey, this function returns the item ID, not ID of its asset.

Threat Level This function does not do a threat level check
Permissions Use of this function is always allowed by default
Extra Delay 0 seconds
Example(s)
// Example for osGetInventoryItemKeys
// This script uses the osGetInventoryKeys function to return a list of keys based on inventory type
 
// Define the inventory type
integer INVENTORY_TYPE = INVENTORY_ALL;
 
// Event handler, that is executed on script start
default
{
    state_entry()
    {
        // Get the list of keys
        list itemUUIDs = osGetInventoryItemKeys(INVENTORY_TYPE);
 
        // Check if the list contains items
        if (llGetListLength(itemUUIDs) > 0)
        {
            // Go through the list and output it to owner chat
            integer numItems = llGetListLength(itemUUIDs);
            string uuidList = "UUIDs of the inventory items:\n";
            integer i;
            for (i = 0; i < numItems; ++i)
            {
                string itemUUID = llList2String(itemUUIDs, i);
                uuidList += itemUUID + "\n";
            }
            llOwnerSay(uuidList);
        }
        else
        {
            // If the list is empty indicate as such
            llOwnerSay("Inventory is empty or not items of inventory type were found");
        }
    }
}
 
 
// Example for osGetLinkInventoryItemKeys
// This script uses the osGetLinkInventoryItemKeys function to return a list of inventory items from a given child prim
 
// Define the child prim
integer CHILD_PRIM_NUMBER = 2;
// Define the inventory type to fetch a list of
integer INVENTORY_TYPE = INVENTORY_ALL;
 
// Event handler, that is executed on script start
default
{
    state_entry()
    {
        // Get the list of keys for the inventory items of the child prim
        list itemUUIDs = osGetLinkInventoryItemKeys(CHILD_PRIM_NUMBER, INVENTORY_TYPE);
 
        // Check if the list contains items
        if (llGetListLength(itemUUIDs) > 0)
        {
            // Go through the list and output it to owner chat
            integer numItems = llGetListLength(itemUUIDs);
            string uuidList = "Inventory UUIDs:\n";
            integer i;
            for (i = 0; i < numItems; ++i)
            {
                string itemUUID = llList2String(itemUUIDs, i);
                uuidList += itemUUID + "\n";
            }
            llOwnerSay(uuidList);
        }
        else
        {
            // If there are not returns indicate as such
            llOwnerSay("There are no items of that inventory type in the child prim");
        }
    }
}
Notes
Added in 0.9.3.0


Personal tools
General
About This Wiki