OsGetInventoryItemKey

From OpenSimulator

Revision as of 11:55, 5 March 2024 by Ubit (Talk | contribs)

Jump to: navigation, search
key osGetInventoryItemKey(string name)

key osGetLinkInventoryItemKey(integer linkNumber, string name)

Returns id(key) of a inventory item within a prim inventory.
If name is not unique result maybe unpredictable.
Note that unlike this function, llGet*InventoryItemKey do not return the item ID but the ID of its asset.
Returns NULL_KEY if the item is not found or Owner has no rights
Threat Level This function does not do a threat level check
Permissions Script owner needs modify, copy and transfer rights
Extra Delay 0 seconds
Example(s)
//
// osGetInventoryItemKey Script Exemple
// Author: Ubit
//
 
default
{
    state_entry()
    {
        llSay(PUBLIC_CHANNEL, "Touch me to see osGetInventoryItemKey usage.");
    }
 
    touch_start(integer number)
    {
        key ItemKey = osGetInventoryItemKey("MyItemName");
        if (ItemKey != NULL_KEY)llSay(PUBLIC_CHANNEL, "Item key is " + osGetInventoryDesc(ItemKey));
        else llSay(PUBLIC_CHANNEL, "The item key is a NULL_KEY, item not found or owner has no rights ...");
    }
}
 
 
// Example for osGetLinkInventoryItemKey
// This script uses the osGetLinkInventoryKey function to fetch the key of a specified inventory item in a specified child prim
 
// Define the child prim
integer CHILD_PRIM_NUMBER = 2;
// Define the inventory item name
string itemName = "INVENTORY_ITEM_NAME";
 
// Event handler, that is executed on script start
default
{
    state_entry()
    {
        // Get the key of the inventory item by name in child prim
        key itemUUID = osGetLinkInventoryItemKey(CHILD_PRIM_NUMBER, itemName);
 
        // Check if the returned key is not NULL_KEY
        if (itemUUID != NULL_KEY)
        {
            // Output the key to owner chat
            llOwnerSay("UUID of the inventory item '" + itemName + "': " + (string)itemUUID);
        }
        else
        {
            // If the key is NULL_KEY then the item was not found
            llOwnerSay("No inventory item named '" + itemName + "' was found");
        }
    }
}
Notes
osGetInventoryItemKey added in 0.9.1.0 Dev, Implemented August, 16 2019

osGetLinkInventoryKey added in 0.9.3.0 Dev, March 2024


See Also:

Personal tools
General
About This Wiki