Difference between revisions of "LlGetInventoryType"

From Second Life Wiki
Jump to navigation Jump to search
m
Line 36: Line 36:
}//Since INVENTORY_ALL == INVENTORY_NONE, the extra part on the end is required to invert the result.</lsl>
}//Since INVENTORY_ALL == INVENTORY_NONE, the extra part on the end is required to invert the result.</lsl>
|also_functions=
|also_functions=
{{LSL DefineRow||[[llGetInventoryCreator]]|}}
{{LSL DefineRow||[[llGetInventoryName]]|Returns the inventory item's name}}
{{LSL DefineRow||[[llGetInventoryKey]]|}}
{{LSL DefineRow||[[llGetInventoryNumber]]|Returns the number of items of a specific type in inventory}}
{{LSL DefineRow||[[llGetInventoryPermMask]]|}}
{{LSL DefineRow||[[llGetInventoryCreator]]|Returns the inventory item's creator}}
{{LSL DefineRow||[[llGetInventoryPermMask]]|Returns the inventory item's permissions}}
{{LSL DefineRow||[[llGetInventoryKey]]|Returns the inventory item's [[UUID]] (if full perm)}}
|also_tests=
|also_tests=
{{LSL DefineRow||[[llGetInventoryType_Test]]}}
{{LSL DefineRow||[[llGetInventoryType_Test]]}}

Revision as of 19:27, 22 November 2008

Summary

Function: integer llGetInventoryType( string name );

Returns an integer that is the type of the inventory item name

• string name name of an inventory item

If the item does not exist, INVENTORY_NONE is returned (no errors or messages are generated).

Flag Inventory Type
INVENTORY_NONE -1 Item does not exist.
INVENTORY_ALL Any inventory type.
INVENTORY_TEXTURE 0 texture
INVENTORY_SOUND 1 sound
INVENTORY_LANDMARK 3 landmark
INVENTORY_CLOTHING 5 clothing
INVENTORY_OBJECT 6 object
Flag Inventory Type
INVENTORY_NOTECARD 7 notecard
INVENTORY_SCRIPT 10 script
INVENTORY_BODYPART 13 body part
INVENTORY_ANIMATION 20 animation
INVENTORY_GESTURE 21 gesture
INVENTORY_SETTING 56 setting
INVENTORY_MATERIAL 57 material

Examples

Useful Snippets

<lsl>string InventoryName(string name, integer type) {//finds an item in a case insensitive fashion of the given type and returns its true name.

   integer a = llGetInventoryType(name); 
   if(!~a)//a == INVENTORY_NONE
   {//it should be noted that INVENTORY_NONE == INVENTORY_ALL == -1; which is why '!~a' works.
       string lc_name = llToLower(name);
       a = llGetInventoryNumber(type);
       while(a)
       {//(a = ~-a) is equivalent to --a, but runs faster.
           if(llToLower(name = llGetInventoryName(type, a = ~-a)) == lc_name)
           {//we found a match ^_^
               return name;
           }
       }
   }
   else if((a == type) ^ (!~type))//return name, as long as a == type or type == INVENTORY_ALL
   {//we already know that a != INVENTORY_NONE, but just in case we use xor instead of or.
       return name;
   }
   return "";//no match ~_~

}

integer InventoryExists(string name, integer type) {//only included to show how this type of check could be done if the value of 'type' is not constant and could be INVENTORY_ALL.

   return (llGetInventoryType(name) == type) ^ (!~type);

}//Since INVENTORY_ALL == INVENTORY_NONE, the extra part on the end is required to invert the result.</lsl>

See Also

Functions

•  llGetInventoryName Returns the inventory item's name
•  llGetInventoryNumber Returns the number of items of a specific type in inventory
•  llGetInventoryCreator Returns the inventory item's creator
•  llGetInventoryPermMask Returns the inventory item's permissions
•  llGetInventoryKey Returns the inventory item's UUID (if full perm)

Deep Notes

Search JIRA for related Issues

Tests

•  llGetInventoryType_Test

Signature

function integer llGetInventoryType( string name );