Equip: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
m moved Equip() to Equip
add new overloads for equipping familiars directly and code example
 
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
'''[[boolean]] equip([[slot]] slottype, item itemtype)'''<br>
{{
'''[[boolean]] equip(item itemtype)'''
#vardefine:name|equip}}{{
#vardefine:return_type|boolean}}{{


FunctionPage|
name={{#var:name}}|


Will attempt to equip the item. If the slot is not provided it will attempt to place it in the 'normal' position for the item. (A hat will be placed in a hat slot, a weapon in the mainhand etc.)
function1={{Function|
name={{#var:name}}|
aggregate={{#var:aggregate}}|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}|
parameter1={{Param|item|equip_me}}|
}}|


The return value indicates whether the item was succesfully equipped or not.
function2={{Function|
name={{#var:name}}|
aggregate={{#var:aggregate}}|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}|
parameter1={{Param|item|equip_me}}|
parameter2={{Param|slot|where}}|


Note: If no slot is selected, accessories will only be placed in empty slots.
}}|
<br><br>
 
<code>
function3={{Function|
equip($slot[acc3],$item[hardened slime belt]);
name={{#var:name}}|
</code>
aggregate={{#var:aggregate}}|
<br>
return_type={{#var:return_type}}|
Attempts to equip the hardened slimt belt in the accessory 3 slot.
return_also={{#var:return_also}}|
<br><br>
parameter1={{Param|slot|where}}|
<code>
parameter2={{Param|item|equip_me}}|
equip($item[rave whistle]);
p1desc={{Pspan|equip_me}} is the item to equip|
</code>
p2desc={{Pspan|where}} is the slot to place the item in|
<br>
}}|
Attempts to equip the rave whistle as the main weapon.
 
function4={{Function|
name={{#var:name}}|
aggregate={{#var:aggregate}}|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}|
parameter1={{Param|item|equip_me}}|
parameter2={{Param|familiar|fam}}|
 
}}|
 
function5={{Function|
name={{#var:name}}|
aggregate={{#var:aggregate}}|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}|
parameter1={{Param|familiar|fam}}|
parameter2={{Param|item|equip_me}}|
p1desc={{Pspan|equip_me}} is the item to equip|
p2desc={{Pspan|where}} is the familiar to equip the item on|
}}|
 
function_description=Attempts to equip the item {{pspan|equip_me}} in the slot {{pspan|where}} if specified, and returns true if the operation was successful, and false if it was not. If parameter {{pspan|where}} is not specified, it defaults to the "standard" place for such an item (main-hand for 1-handed weapons, first open slot for accessories or acc1 if no slots are open).
*If {{pspan|where}} is specified and {{pspan|equip_me}} is set to $item[none], this function will unequip whatever is in slot {{pspan|where}} and return true.
*If {{pspan|where}} is not specified and {{pspan|equip_me}} is set to $item[none], the function aborts and you get a funky error because that makes no sense.
*If you cannot equip {{pspan|equip_me}}, or {{pspan|where}} is supplied and the item cannot be used in that slot, you will be given an error message and this function will return false.
*The overload for equipping a familiar with {{pspan|equip_me}} can be used to equip familiars with familiar equipment without requiring the familiar to be your currently active familiar. This will return false if you don't have (or can't use) the familiar or if the familiar can't equip the item you are attempting to equip.
&nbsp;|
 
code1={{CodeSample|
title=Code Sample|
description=Equips the Swashbuckling Getup carefully to ensure that the parrot is in the second accessory slot.|
code=
<syntaxhighlight>
equip($item[eyepatch]);
equip($item[swashbuckling pants]);
equip($slot[acc2], $item[stuffed shoulder parrot]);
</syntaxhighlight>
}}|
 
code2={{CodeSample|
title=Code Sample|
description=Equips the blue plate on the Shorter-Order Cook without switching to it first.|
code=
<syntaxhighlight>
equip($familiar[shorter-order cook], $item[blue plate]);
</syntaxhighlight>
}}|
 
see_also={{SeeAlso|can_equip|equipped_amount|equipped_item|have_equipped}}|
cli_equiv=The CLI commands "equip" (and others, for specific slots) function similarly.|
}}
 
[[Category:Equipment]]

Latest revision as of 16:49, 12 April 2024

Function Syntax

boolean equip(item equip_me )

boolean equip(item equip_me ,slot where )

boolean equip(slot where ,item equip_me )

  • equip_me is the item to equip
  • where is the slot to place the item in

boolean equip(item equip_me ,familiar fam )

boolean equip(familiar fam ,item equip_me )

  • equip_me is the item to equip
  • where is the familiar to equip the item on

Attempts to equip the item equip_me in the slot where if specified, and returns true if the operation was successful, and false if it was not. If parameter where is not specified, it defaults to the "standard" place for such an item (main-hand for 1-handed weapons, first open slot for accessories or acc1 if no slots are open).

  • If where is specified and equip_me is set to $item[none], this function will unequip whatever is in slot where and return true.
  • If where is not specified and equip_me is set to $item[none], the function aborts and you get a funky error because that makes no sense.
  • If you cannot equip equip_me, or where is supplied and the item cannot be used in that slot, you will be given an error message and this function will return false.
  • The overload for equipping a familiar with equip_me can be used to equip familiars with familiar equipment without requiring the familiar to be your currently active familiar. This will return false if you don't have (or can't use) the familiar or if the familiar can't equip the item you are attempting to equip.

 

Code Sample

Equips the Swashbuckling Getup carefully to ensure that the parrot is in the second accessory slot.

equip($item[eyepatch]);
equip($item[swashbuckling pants]);
equip($slot[acc2], $item[stuffed shoulder parrot]);

Code Sample

Equips the blue plate on the Shorter-Order Cook without switching to it first.

equip($familiar[shorter-order cook], $item[blue plate]);

CLI Equivalent

The CLI commands "equip" (and others, for specific slots) function similarly.

See Also

can_equip() | equipped_amount() | equipped_item() | have_equipped()