Item type: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
No edit summary
imported>Heeheehee
Added code example.
Line 15: Line 15:
}}|
}}|


function_description=Returns the type of equipment that {{pspan|check_me}} is categorized as. Possible values are hat, sword, staff, chefstaff, whip, shield, offhand, pants, accessory, familiar equipment, shirt and container.|
function_description=Returns the type of equipment that {{pspan|check_me}} is categorized as. Possible values are hat, [http://kol.coldfront.net/thekolwiki/index.php/Category:Weapons (various weapon types)], shield, offhand, pants, accessory, familiar equipment, shirt, container, hp restore, mp restore, hp+mp restore, food, booze, drink helper, food helper, and familiar larva.|


needscode=yes|
code1={{CodeSample|
title=Simple Example|
description=A universal consume function.|
code=
<syntaxhighlight>
if(item_type(it)=="food") eat(qty,it);
else if(item_type(it)=="booze") {
if() drink(qty,it);
else return false;
}
else use(qty,it);
// Note: this example doesn't check your drunkenness, so it isn't practical for normal use.
</syntaxhighlight>}}


see_also={{SeeAlso|weapon_hands|weapon_type}}|
see_also={{SeeAlso|weapon_hands|weapon_type}}|
special= For non-equipment, this function returns an empty string.|
special= For non-equipment, this function returns an empty string.|
}}
}}

Revision as of 18:48, 6 March 2010



Function Syntax

string item_type(item check_me )

  • check_me is the equipment to check

Returns the type of equipment that check_me is categorized as. Possible values are hat, (various weapon types), shield, offhand, pants, accessory, familiar equipment, shirt, container, hp restore, mp restore, hp+mp restore, food, booze, drink helper, food helper, and familiar larva.

Simple Example

A universal consume function.

if(item_type(it)=="food") eat(qty,it);
else if(item_type(it)=="booze") {
	if() drink(qty,it);
	else return false;
}
else use(qty,it);
// Note: this example doesn't check your drunkenness, so it isn't practical for normal use.


see_also=

See Also

weapon_hands() | weapon_type()

Special

For non-equipment, this function returns an empty string.