Difference between revisions of "LlGetInventoryType"

From Second Life Wiki
Jump to navigation Jump to search
Line 47: Line 47:
|notes
|notes
|constants=
|constants=
{| {{Prettytable}}
<table style="{{Prettytable}}" valign="top">
|- valign="top"
<tr>
|| '''Flag'''
<td> '''Flag'''
|| '''Value'''
<td> '''Value'''
|| '''Inventory Type'''
<td> '''Inventory Type'''
|-
<tr>
|| <tt>INVENTORY_NONE</tt><br/><tt>INVENTORY_ALL</tt>
<td> <tt>INVENTORY_NONE</tt><br/><tt>INVENTORY_ALL</tt>
|| -1
<td> -1
|| Item does not exist
<td> Item does not exist
|-
<tr>
|| <tt>INVENTORY_TEXTURE</tt>
<td> <tt>INVENTORY_TEXTURE</tt>
|| 0
<td> 0
|| [[texture]]
<td> [[texture]]
|-
<tr>
|| <tt>INVENTORY_SOUND</tt>
<td> <tt>INVENTORY_SOUND</tt>
|| 1
<td> 1
|| [[sound]]
<td> [[sound]]
|-
<tr>
|| <tt>INVENTORY_LANDMARK</tt>
<td> <tt>INVENTORY_LANDMARK</tt>
|| 3
<td> 3
|| [[landmark]]
<td> [[landmark]]
|-
<tr>
|| <tt>INVENTORY_CLOTHING</tt>
<td> <tt>INVENTORY_CLOTHING</tt>
|| 5
<td> 5
|| clothing
<td> clothing
|-
<tr>
|| <tt>INVENTORY_OBJECT</tt>
<td> <tt>INVENTORY_OBJECT</tt>
|| 6
<td> 6
|| [[object]]
<td> [[object]]
|-
<tr>
|| <tt>INVENTORY_NOTECARD</tt>
<td> <tt>INVENTORY_NOTECARD</tt>
|| 7
<td> 7
|| [[notecard]]
<td> [[notecard]]
|-
<tr>
|| <tt>INVENTORY_SCRIPT</tt>
<td> <tt>INVENTORY_SCRIPT</tt>
|| 10
<td> 10
|| [[script]]
<td> [[script]]
|-
<tr>
|| <tt>INVENTORY_BODYPART</tt>
<td> <tt>INVENTORY_BODYPART</tt>
|| 13
<td> 13
|| body part
<td> body part
|-
<tr>
|| <tt>INVENTORY_ANIMATION</tt>
<td> <tt>INVENTORY_ANIMATION</tt>
|| 20
<td> 20
|| [[animation]]
<td> [[animation]]
|-
<tr>
|| <tt>INVENTORY_GESTURE</tt>
<td> <tt>INVENTORY_GESTURE</tt>
|| 21
<td> 21
|| [[gesture]]
<td> [[gesture]]
|}
</table>
}}
}}


[[Category:LSL_Functions]]
[[Category:LSL_Functions]]
[[Category:LSL_Inventory]]
[[Category:LSL_Inventory]]

Revision as of 22:57, 25 January 2007

   Outdated templated used

Please change the template from 'LSLFunctionAll' to 'LSL_Function' (just replace 'LSLFunctionAll' with 'LSL_Function', do this after fixing any other erorr messages.

Summary

Function: integer llGetInventoryType( string name );

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

• string name The name of an inventory item.

This function returns the inventory type of the requested inventory item.
If the item does not exist, INVENTORY_NONE is returned.

Flag Value Inventory Type
INVENTORY_NONE
INVENTORY_ALL
-1 Item does not exist
INVENTORY_TEXTURE 0 texture
INVENTORY_SOUND 1 sound
INVENTORY_LANDMARK 3 landmark
INVENTORY_CLOTHING 5 clothing
INVENTORY_OBJECT 6 object
INVENTORY_NOTECARD 7 notecard
INVENTORY_SCRIPT 10 script
INVENTORY_BODYPART 13 body part
INVENTORY_ANIMATION 20 animation
INVENTORY_GESTURE 21 gesture

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, aslong as a == type or type == INVENTORY_ALL
   {//we already know that a != INVENTORY_NONE, but just incase 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>

Deep Notes

Search JIRA for related Issues

Signature

function integer llGetInventoryType( string name );