Difference between revisions of "LlGetInventoryType"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
{{ | {{LSL_Function | ||
|func_id=301 | |func_id=301|func_sleep=0.0|func_energy=10.0 | ||
|func_sleep=0.0 | |func=llGetInventoryType|sort=GetInventoryType | ||
|func_energy=10.0 | |||
|func=llGetInventoryType | |||
|return_type=integer | |return_type=integer | ||
|p1_type=string | |p1_type=string|p1_name=name|p1_desc=The name of an inventory item. | ||
|p1_name=name | |||
|p1_desc=The name of an inventory item. | |||
|func_footnote=If the item does not exist, INVENTORY_NONE is returned. | |func_footnote=If the item does not exist, INVENTORY_NONE is returned. | ||
|return_text=that is the type of the inventory item name | |return_text=that is the type of the inventory item '''name''' | ||
|spec | |spec | ||
|caveats | |caveats | ||
|examples | |examples | ||
|helpers= | |helpers=<pre> | ||
< | |||
string InventoryName(string name, integer type) | string InventoryName(string name, integer type) | ||
{//finds an item in a case insensitive fashion of the given type and returns its true name. | {//finds an item in a case insensitive fashion of the given type and returns its true name. | ||
Line 30: | Line 25: | ||
} | } | ||
} | } | ||
else if((a == type) ^ (!~type))//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 | {//we already know that a != INVENTORY_NONE, but just in case we use xor instead of or. | ||
return name; | return name; | ||
} | } | ||
Line 41: | Line 36: | ||
return (llGetInventoryType(name) == type) ^ (!~type); | return (llGetInventoryType(name) == type) ^ (!~type); | ||
}//Since INVENTORY_ALL == INVENTORY_NONE, the extra part on the end is required to invert the result. | }//Since INVENTORY_ALL == INVENTORY_NONE, the extra part on the end is required to invert the result. | ||
</ | </pre> | ||
|related | |related | ||
|also | |also | ||
|notes | |notes | ||
|constants={{LSL_Constants_Inventory}} | |constants={{LSL_Constants_Inventory}} | ||
|cat1=Inventory | |||
|cat2 | |||
|cat3 | |||
|cat4 | |||
}} | }} | ||
Revision as of 20:31, 11 February 2007
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: integer llGetInventoryType( string name );301 | Function ID |
0.0 | Forced Delay |
10.0 | Energy |
Returns an integer that is the type of the inventory item name
• string | name | – | The name of an inventory item. |
If the item does not exist, INVENTORY_NONE is returned.
|
|
Caveats
Examples
Useful Snippets
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.