Equip: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
mNo edit summary
add new overloads for equipping familiars directly and code example
 
(7 intermediate revisions by 3 users not shown)
Line 5: Line 5:
FunctionPage|
FunctionPage|
name={{#var:name}}|
name={{#var:name}}|
function_category=Equipment|


function1={{Function|
function1={{Function|
Line 12: Line 11:
return_type={{#var:return_type}}|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}|
return_also={{#var:return_also}}|
parameter2={{Param|item|equip_me}}|
parameter1={{Param|item|equip_me}}|
}}|
}}|


function2={{Function|
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}}|
}}|
function3={{Function|
name={{#var:name}}|
name={{#var:name}}|
aggregate={{#var:aggregate}}|
aggregate={{#var:aggregate}}|
Line 22: Line 31:
parameter1={{Param|slot|where}}|
parameter1={{Param|slot|where}}|
parameter2={{Param|item|equip_me}}|
parameter2={{Param|item|equip_me}}|
p1desc={{Pspan|where}} is the slot to place the item in (optional)|
p1desc={{Pspan|equip_me}} is the item to equip|
p2desc={{Pspan|equip_me}} is the item to equip|
p2desc={{Pspan|where}} is the slot to place the item in|
}}|
}}|


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|where}} 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|where}} is set to $item[none], the function aborts and you get a funky error. 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.|
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.
 |


code1={{CodeSample|
code1={{CodeSample|
title=Code Sample|
title=Code Sample|
description=Equips the Swashbuckling Getup carefully to ensure that the parot is in the second accessory slot.|
description=Equips the Swashbuckling Getup carefully to ensure that the parrot is in the second accessory slot.|
code=
code=
<syntaxhighlight>
<syntaxhighlight>
Line 36: Line 71:
equip($item[swashbuckling pants]);
equip($item[swashbuckling pants]);
equip($slot[acc2], $item[stuffed shoulder parrot]);
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>
</syntaxhighlight>
}}|
}}|
Line 42: Line 86:
cli_equiv=The CLI commands "equip" (and others, for specific slots) function similarly.|
cli_equiv=The CLI commands "equip" (and others, for specific slots) function similarly.|
}}
}}
{{RFI|What's up with the abort message when no slot is specified and item is $item[none]?|I'm sure there are other edge-case I haven't thought of; if you do, please test and edit in.}}
 
[[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()