Difference between pages "To coinmaster" and "Equip"

From Kolmafia
(Difference between pages)
Jump to navigation Jump to search
imported>Bale
(r9555)
 
(add new overloads for equipping familiars directly and code example)
 
Line 1: Line 1:
 
{{
 
{{
#vardefine:name|to_coinmaster}}{{
+
#vardefine:name|equip}}{{
#vardefine:return_type|coinmaster}}{{
+
#vardefine:return_type|boolean}}{{
  
 
FunctionPage|
 
FunctionPage|
Line 9: Line 9:
 
name={{#var:name}}|
 
name={{#var:name}}|
 
aggregate={{#var:aggregate}}|
 
aggregate={{#var:aggregate}}|
return_type=boolean|
+
return_type={{#var:return_type}}|
 
return_also={{#var:return_also}}|
 
return_also={{#var:return_also}}|
parameter1={{Param|string|store}}|
+
parameter1={{Param|item|equip_me}}|
p1desc={{pspan|store}} is hopefully the name of a coinmaster|
 
 
}}|
 
}}|
  
function_description=Returns the coinmaster that matches the string {{pspan|store}}. This is useful so that the coinmaster datatype can be used by other functions. If {{pspan|store}} does not match the name of any coinmaster, then the function returns $coinmaster[none]. This works on partial matches so that if {{pspan|store}} is "dime", this function will return $coinmaster[Dimemaster].|
+
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}}|
 +
aggregate={{#var:aggregate}}|
 +
return_type={{#var:return_type}}|
 +
return_also={{#var:return_also}}|
 +
parameter1={{Param|slot|where}}|
 +
parameter2={{Param|item|equip_me}}|
 +
p1desc={{Pspan|equip_me}} is the item to equip|
 +
p2desc={{Pspan|where}} is the slot to place the item in|
 +
}}|
 +
 
 +
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=This sells off all the Island War vendor trash to the appropriate coinmasters for quarters and dimes.|
+
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=
 
code=
 
<syntaxhighlight>
 
<syntaxhighlight>
foreach trash in $items[red class ring, blue class ring, white class ring, PADL Phone,
+
equip($familiar[shorter-order cook], $item[blue plate]);
pink clay bead, purple clay bead, green clay bead, communications windchimes]
 
  if(item_amount(trash) > 0)
 
      sell(to_coinmaster(trash.buyer), item_amount(trash), trash);
 
 
</syntaxhighlight>
 
</syntaxhighlight>
 
}}|
 
}}|
  
see_also={{SeeAlso|visit|is_accessible|buys_item|sells_item}}|
+
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:Item Management]]
+
[[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()