OsGetInventoryItemKey: Difference between revisions
From OpenSimulator
Jump to navigationJump to search
imported>Djphil mNo edit summary |
No edit summary |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 3: | Line 3: | ||
|permissions=Script owner needs modify, copy and transfer rights | |permissions=Script owner needs modify, copy and transfer rights | ||
|delay=0 | |delay=0 | ||
|function_syntax=key osGetInventoryItemKey(string name) | |function_syntax=key osGetInventoryItemKey(string name)<br> | ||
key osGetLinkInventoryItemKey(integer linkNumber, string name)<br> | |||
|ossl_example=<source lang="lsl"> | |ossl_example=<source lang="lsl"> | ||
// | // | ||
// osGetInventoryItemKey Script Exemple | // osGetInventoryItemKey Script Exemple | ||
// Author: Ubit | |||
// | // | ||
| Line 21: | Line 24: | ||
if (ItemKey != NULL_KEY)llSay(PUBLIC_CHANNEL, "Item key is " + osGetInventoryDesc(ItemKey)); | 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 ..."); | 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"); | |||
} | |||
} | } | ||
} | } | ||
</source> | </source> | ||
|description=Returns id(key) of a inventory item within | |description=Returns id(key) of a inventory item within a prim inventory.<br> If name is not unique result maybe unpredictable.<br> Note that unlike llGetInventoryKey, this function returns the item ID, not ID of its asset..<br>Returns NULL_KEY if the item is not found or Owner has no rights | ||
|additional_info= | |additional_info=osGetInventoryItemKey added in 0.9.1.0 Dev, Implemented August, 16 2019 <br> | ||
Implemented August, 16 2019 | osGetLinkInventoryKey added in 0.9.3.0 Dev, March 2024 | ||
}} | }} | ||
'''See Also:''' | '''See Also:''' | ||
* [[osGetInventoryName]] | * [[osGetInventoryName]] | ||
* [[osGetInventoryDesc]] | * [[osGetInventoryDesc]] | ||
* [[osGetInventoryLastOwner]] | * [[osGetInventoryLastOwner]] | ||
* [[osGetLastChangedEventKey]] | * [[osGetLastChangedEventKey]] | ||
Latest revision as of 16:10, 19 March 2024
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 llGetInventoryKey, this function returns the item ID, not 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: