OsGetInventoryItemKeys

From OpenSimulator

Revision as of 03:52, 19 March 2024 by Manni (Talk | contribs)

Jump to: navigation, search
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