Retrieve item: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>MapleMario
New page: '''boolean retrieve_item( int quantity, item it )''' <br />uses KoLmafia internal logic to gather the items in the least destructive manner. ''See the “acquire” documentation in the CL...
 
fixed wrong syntax in special which caused on of the special notes to not show up.
 
(12 intermediate revisions by 5 users not shown)
Line 1: Line 1:
'''boolean retrieve_item( int quantity, item it )'''
{{
<br />uses KoLmafia internal logic to gather the items in the least destructive manner. ''See the “acquire” documentation in the CLI manual for more details.''
#vardefine:name|retrieve_item}}{{
#vardefine:return_type|boolean}}{{


<p><pre># function to get your class-specific Epic Weapon hermit item
FunctionPage|
boolean get_epic_item()
name={{#var:name}}|
 
function1={{Function|
name={{#var:name}}|
aggregate={{#var:aggregate}}|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}|
parameter1={{Param|int|qty}}|
parameter2={{Param|item|get}}|
p1desc={{Pspan|qty}} is the quantity to acquire|
p2desc={{Pspan|get}} is the item to acquire|
}}|
 
function_description=Uses KoLmafia's internal logic to gather the items in the least destructive manner. Returns true if items are acquired as specified and false if not.|
 
code1={{CodeSample|
title=Code Sample|
description=This is an example of a very simple aftercore logout script.|
code=<syntaxhighlight>
item nightcap = $item[ Mon Tiki ];
while (my_inebriety() <= inebriety_limit())
{
{
  if ( !retrieve_item( 1 , nightcap ) )
      abort( "Could not make/buy a " + nightcap + " for a nightcap." );
  else
      overdrink( 1 , nightcap );
}
</syntaxhighlight>
}}|


  item[class] epic_items;
  epic_items[$class[seal clubber]] = $item[seal tooth];
  epic_items[$class[turtle tamer]] = $item[chisel];
  epic_items[$class[pastamancer]] = $item[petrified noodles];
  epic_items[$class[sauceror]] = $item[jabañero pepper];
  epic_items[$class[disco bandit]] = $item[banjo strings];
  epic_items[$class[accordion thief]] = $item[hot buttered roll];


  return retrieve_item(1, epic_items[my_class()]);
see_also={{SeeAlso|buy}}|
cli_equiv=The CLI command "acquire" works similarly.|
special=Unlike a few other ASH commands, retrieve_item() will still return false on attempts to acquire items that are not possible to get (such as a sparkly engagement ring).
<br>
This function and it's CLI equivalent "acquire" will not purchase items from the mall that can not be discarded. This is because many of those items are surprisingly expensive. Such items can be detected by checking to see if their {{f|autosell_price}} is 0. There are a few hard-coded exceptions to this rule: clovers, phials, divine favors, love songs and white rice can all be purchased with this command despite not being discardable.|
more_info=For information on order of operations, see [[Retrieval order]].|
}}
{{RFI|Are there exceptions to the info listed under Special?}}


}</pre></p>
[[Category:Item Management]]

Latest revision as of 22:03, 27 December 2022

Function Syntax

boolean retrieve_item(int qty ,item get )

  • qty is the quantity to acquire
  • get is the item to acquire

Uses KoLmafia's internal logic to gather the items in the least destructive manner. Returns true if items are acquired as specified and false if not.

Code Sample

This is an example of a very simple aftercore logout script.

item nightcap = $item[ Mon Tiki ];
while (my_inebriety() <= inebriety_limit())
{
   if ( !retrieve_item( 1 , nightcap ) )
      abort( "Could not make/buy a " + nightcap + " for a nightcap." );
   else
      overdrink( 1 , nightcap );
}

CLI Equivalent

The CLI command "acquire" works similarly.

See Also

buy()

More Information

For information on order of operations, see Retrieval order.

Special

Unlike a few other ASH commands, retrieve_item() will still return false on attempts to acquire items that are not possible to get (such as a sparkly engagement ring).


This function and it's CLI equivalent "acquire" will not purchase items from the mall that can not be discarded. This is because many of those items are surprisingly expensive. Such items can be detected by checking to see if their autosell_price() is 0. There are a few hard-coded exceptions to this rule: clovers, phials, divine favors, love songs and white rice can all be purchased with this command despite not being discardable.


Attention KoLmafia Experts!

We need your help; some details of this function's operation are unknown or unclear.

The following specific question has been raised:

  • Are there exceptions to the info listed under Special?