LlGetInventoryType: Difference between revisions
Jump to navigation
Jump to search
Kireji Haiku (talk | contribs) added example script |
m Very minor text changes; replaced <source> with <syntaxhighlight>; added Haiku created with Poem Generator (it doesn't make sense, but Haikus are not necessarily supposed to make sense) |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 4: | Line 4: | ||
|return_type=integer | |return_type=integer | ||
|p1_type=string|p1_name=name|p1_desc=name of an inventory item | |p1_type=string|p1_name=name|p1_desc=name of an inventory item | ||
|func_footnote=If {{LSLP|name}} does not exist, [[INVENTORY_NONE]] is returned (no errors or messages are generated), making this function ideal for testing the existence of inventory. | |func_footnote=If {{LSLP|name}} does not exist, [[INVENTORY_NONE]] is returned (no errors or messages are generated), making this function ideal for testing the existence of a certain item in [[inventory]]. | ||
|return_text=that is the type of the inventory item {{LSLP|name}} | |return_text=that is the type of the inventory item {{LSLP|name}} | ||
|spec | |spec | ||
|caveats | |caveats | ||
|examples= | |examples= | ||
< | <syntaxhighlight lang="lsl2"> | ||
string get_type_info(integer inputInteger) | string get_type_info(integer inputInteger) | ||
{ | { | ||
if (inputInteger == | if (inputInteger == INVENTORY_TEXTURE) | ||
return "INVENTORY_TEXTURE"; | return "INVENTORY_TEXTURE"; | ||
else if (inputInteger == | else if (inputInteger == INVENTORY_SOUND) | ||
return "INVENTORY_SOUND"; | return "INVENTORY_SOUND"; | ||
else if (inputInteger == | else if (inputInteger == INVENTORY_LANDMARK) | ||
return "INVENTORY_LANDMARK"; | return "INVENTORY_LANDMARK"; | ||
else if (inputInteger == | else if (inputInteger == INVENTORY_CLOTHING) | ||
return "INVENTORY_CLOTHING"; | return "INVENTORY_CLOTHING"; | ||
else if (inputInteger == | else if (inputInteger == INVENTORY_OBJECT) | ||
return "INVENTORY_OBJECT"; | return "INVENTORY_OBJECT"; | ||
else if (inputInteger == | else if (inputInteger == INVENTORY_NOTECARD) | ||
return "INVENTORY_NOTECARD"; | return "INVENTORY_NOTECARD"; | ||
else if (inputInteger == | else if (inputInteger == INVENTORY_SCRIPT) | ||
return "INVENTORY_SCRIPT"; | return "INVENTORY_SCRIPT"; | ||
else if (inputInteger == | else if (inputInteger == INVENTORY_BODYPART) | ||
return "INVENTORY_BODYPART"; | return "INVENTORY_BODYPART"; | ||
else if (inputInteger == | else if (inputInteger == INVENTORY_ANIMATION) | ||
return "INVENTORY_ANIMATION"; | return "INVENTORY_ANIMATION"; | ||
else if (inputInteger == | else if (inputInteger == INVENTORY_GESTURE) | ||
return "INVENTORY_GESTURE"; | return "INVENTORY_GESTURE"; | ||
else | else if (inputInteger == INVENTORY_SETTING) | ||
return "INVENTORY_SETTING"; | |||
// else | |||
return "<!-- inventory type unknown --!>"; | return "<!-- inventory type unknown --!>"; | ||
} | } | ||
Line 60: | Line 63: | ||
// PUBLIC_CHANNEL has the integer value 0 | // PUBLIC_CHANNEL has the integer value 0 | ||
llSay(PUBLIC_CHANNEL, | llSay(PUBLIC_CHANNEL, | ||
" | "'" + itemName + "' (" + get_type_info(type) + ")"); | ||
++index; | ++index; | ||
Line 66: | Line 69: | ||
} | } | ||
} | } | ||
</ | </syntaxhighlight> | ||
|helpers=< | |helpers=<syntaxhighlight lang="lsl2">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. | ||
integer a = llGetInventoryType(name); | integer a = llGetInventoryType(name); | ||
Line 92: | Line 95: | ||
{//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. | {//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); | 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.</syntaxhighlight> | ||
|also_functions= | |also_functions= | ||
{{LSL DefineRow||[[llGetInventoryAcquireTime]]|Returns the time the item was added to the prim's inventory}} | |||
{{LSL DefineRow||[[llGetInventoryName]]|Returns the inventory item's name}} | {{LSL DefineRow||[[llGetInventoryName]]|Returns the inventory item's name}} | ||
{{LSL DefineRow||[[llGetInventoryNumber]]|Returns the number of items of a specific type in inventory}} | {{LSL DefineRow||[[llGetInventoryNumber]]|Returns the number of items of a specific type in inventory}} | ||
Line 105: | Line 109: | ||
|notes | |notes | ||
|history | |history | ||
|haiku={{Haiku|Sleepy afternoon|A large, inventory finds|enjoying the type}} | |||
|constants={{LSL_Constants_Inventory}} | |constants={{LSL_Constants_Inventory}} | ||
|cat1=Inventory | |cat1=Inventory |
Revision as of 11:02, 13 April 2022
{{LSL_Function |func_id=301|func_sleep=0.0|func_energy=10.0 |func=llGetInventoryType |return_type=integer |p1_type=string|p1_name=name|p1_desc=name of an inventory item |func_footnote=If name does not exist, INVENTORY_NONE is returned (no errors or messages are generated), making this function ideal for testing the existence of a certain item in inventory. |return_text=that is the type of the inventory item name |spec |caveats |examples= <syntaxhighlight lang="lsl2"> string get_type_info(integer inputInteger) {
if (inputInteger == INVENTORY_TEXTURE) return "INVENTORY_TEXTURE"; else if (inputInteger == INVENTORY_SOUND) return "INVENTORY_SOUND"; else if (inputInteger == INVENTORY_LANDMARK) return "INVENTORY_LANDMARK"; else if (inputInteger == INVENTORY_CLOTHING) return "INVENTORY_CLOTHING"; else if (inputInteger == INVENTORY_OBJECT) return "INVENTORY_OBJECT"; else if (inputInteger == INVENTORY_NOTECARD) return "INVENTORY_NOTECARD"; else if (inputInteger == INVENTORY_SCRIPT) return "INVENTORY_SCRIPT"; else if (inputInteger == INVENTORY_BODYPART) return "INVENTORY_BODYPART"; else if (inputInteger == INVENTORY_ANIMATION) return "INVENTORY_ANIMATION"; else if (inputInteger == INVENTORY_GESTURE) return "INVENTORY_GESTURE"; else if (inputInteger == INVENTORY_SETTING) return "INVENTORY_SETTING";
// else
return "