Difference between revisions of "LlGetInventoryKey"

From Second Life Wiki
Jump to navigation Jump to search
Line 1: Line 1:
{{Issues/SVC-4050}}{{LSL_Function/inventory|name|uuid=false|type}}
{{Issues/SVC-3670}}{{Issues/SVC-4050}}{{LSL_Function/inventory|name|uuid=false}}
{{LSL_Function
{{LSL_Function
|func_id=175|func_sleep=0.0|func_energy=10.0
|func_id=175|func_sleep=0.0|func_energy=10.0
Line 8: Line 8:
|return_text=that is the [[UUID]] of the inventory '''name'''
|return_text=that is the [[UUID]] of the inventory '''name'''
|spec
|spec
|caveats=*Function does not work for scripts or objects. See {{Jira|SVC-3670}}.
|caveats=*New empty notecards will return [[NULL_KEY]]{{Footnote|This happens because new notecards (as inventory items) do not have an attached asset, strictly speaking they do not exist until modified (and saved).}}.
|constants
|constants
|examples=<lsl>string notecard_name = "Default";
|examples=<lsl>string item = "Default";


default
default
Line 16: Line 16:
     state_entry()
     state_entry()
     {
     {
         llOwnerSay("Touch to get the key for \"" + notecard_name + "\".");
         llOwnerSay("Touch to get information about \"" + item + "\".");
     }
     }


     touch_start(integer total_number)
     touch_start(integer total_number)
     {
     {
         key notecard_key = llGetInventoryKey(notecard_name);
         integer type = llGetInventoryType(item);
        integer index = llListFindList([INVENTORY_NONE, INVENTORY_TEXTURE, INVENTORY_SOUND, INVENTORY_LANDMARK, INVENTORY_CLOTHING,  INVENTORY_OBJECT,INVENTORY_NOTECARD, INVENTORY_SCRIPT, INVENTORY_BODYPART, INVENTORY_ANIMATION, INVENTORY_GESTURE], [type]);
        string name = llList2String(["does not exist", "texture", "sound", "landmark", "clothing", "object", "notecard", "script", "body part", "animation", "gesture"], index);
 
        llOwnerSay("Type: " + name);
       
        if(type == INVENTORY_NONE)
            return;
       
        integer owner_perms = llGetInventoryPermMask(item, MASK_OWNER);
        list perms;
        if(owner_perms & PERM_COPY)
            perms += "Copy";
       
        if(owner_perms & PERM_MODIFY)
            perms += "Modify";
       
        if(owner_perms & PERM_TRANSFER)
            perms += "Transfer";
 
        if(owner_perms & PERM_MOVE)
            perms += "Move";
       
        llOwnerSay("Perms: " + llList2CSV(perms));
          
          
         if(notecard_key != NULL_KEY)
        integer temp = PERM_COPY | PERM_MODIFY | PERM_TRANSFER;
        {
         if((owner_perms & temp) != temp)
             llOwnerSay("The key for \"" + notecard_name + "\" is \"" + (string)notecard_key + "\"");
             return;
        }
 
        else
         llOwnerSay("Perms: " + llGetInventoryKey(item));
         {
            llOwnerSay("Notecard not found.");
        }
     }
     }
}
}
Line 44: Line 64:
|also_tests
|also_tests
|also_articles
|also_articles
|notes
|notes=The UUID returned is that of the of asset to which the inventory item points, it is not the UUID of the inventory asset. By having the two separate multiple inventory items can point to a single asset without needing the asset be duplicated.
|history=
* 0.2 - Introduced during the closed beta period.
* 1.2 - Restricted to full perm inventory items only.
* 1.24 - Objects and scripts no longer return their actual UUID but a hash instead. -- {{JIRA|SVC-3670}}
|cat1=Inventory
|cat1=Inventory
|cat2=Key
|cat2=Key

Revision as of 18:13, 30 March 2009

Summary

Function: key llGetInventoryKey( string name );

Returns a key that is the UUID of the inventory name

• string name an item in the inventory of the prim this script is in

If item is not copy, mod, trans then the return is NULL_KEY

Caveats

  • If name is missing from the prim's inventory then an error is shouted on DEBUG_CHANNEL.
  • New empty notecards will return NULL_KEY[1].

Important Issues

~ All Issues ~ Search JIRA for related Bugs
   llGetInventoryKey() returns NULL_KEY when referencing a notecard that is empty

Examples

<lsl>string item = "Default";

default {

   state_entry()
   {
       llOwnerSay("Touch to get information about \"" + item + "\".");
   }
   touch_start(integer total_number)
   {
       integer type = llGetInventoryType(item);
       integer index = llListFindList([INVENTORY_NONE, INVENTORY_TEXTURE, INVENTORY_SOUND, INVENTORY_LANDMARK, INVENTORY_CLOTHING,  INVENTORY_OBJECT,INVENTORY_NOTECARD, INVENTORY_SCRIPT, INVENTORY_BODYPART, INVENTORY_ANIMATION, INVENTORY_GESTURE], [type]);
       string name = llList2String(["does not exist", "texture", "sound", "landmark", "clothing", "object", "notecard", "script", "body part", "animation", "gesture"], index);
       llOwnerSay("Type: " + name);
       
       if(type == INVENTORY_NONE)
           return;
       
       integer owner_perms = llGetInventoryPermMask(item, MASK_OWNER);
       list perms;
       if(owner_perms & PERM_COPY)
           perms += "Copy";
       
       if(owner_perms & PERM_MODIFY)
           perms += "Modify";
       
       if(owner_perms & PERM_TRANSFER)
           perms += "Transfer";
       if(owner_perms & PERM_MOVE)
           perms += "Move";
       
       llOwnerSay("Perms: " + llList2CSV(perms));
       
integer temp = PERM_COPY

Notes

The UUID returned is that of the of asset to which the inventory item points, it is not the UUID of the inventory asset. By having the two separate multiple inventory items can point to a single asset without needing the asset be duplicated.

See Also

Functions

•  llGetInventoryName Returns the inventory item's name
•  llGetInventoryType Tests to see if an inventory item exists and returns its type
•  llGetInventoryNumber Returns the number of items of a specific type in inventory
•  llGetInventoryPermMask Returns the inventory item's permissions
•  llGetInventoryCreator Returns the inventory item's creator

Deep Notes

History

  • 0.2 - Introduced during the closed beta period.
  • 1.2 - Restricted to full perm inventory items only.
  • 1.24 - Objects and scripts no longer return their actual UUID but a hash instead. -- SVC-3670

All Issues

~ Search JIRA for related Issues
   llGetInventoryKey() returns NULL_KEY when it shouldn't
   llGetInventoryKey() returns NULL_KEY when referencing a notecard that is empty

Footnotes

  1. ^ This happens because new notecards (as inventory items) do not have an attached asset, strictly speaking they do not exist until modified (and saved).

Signature

function key llGetInventoryKey( string name );