Retrieve item: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Jasonharper
order of operations
fixed wrong syntax in special which caused on of the special notes to not show up.
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{#vardefine:name|retrieve_item}}
{{
{{#vardefine:return_type|boolean}}
#vardefine:name|retrieve_item}}{{
#vardefine:return_type|boolean}}{{


{{FunctionPage|
FunctionPage|
name={{#var:name}}|
name={{#var:name}}|
function_category=Item Management|
second_category=Adventuring|


function1={{Function|
function1={{Function|
Line 20: Line 19:
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.|
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.|


needscode=yes|
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>
}}|
 


see_also={{SeeAlso|buy}}|
see_also={{SeeAlso|buy}}|
cli_equiv=The CLI command "acquire" works similarly.|
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).
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]].|
}}
}}
<h2>Order of operations</h2>
This is the current order in which retrieval options are tried, as of about r8200.  Note that this is an extremely condensed summary of several hundred lines of internal code, and that the details are subject to change
* items already in inventory
* items currently equipped
* items equipped on a non-current familiar
* retrieval of worthless items by using 31337 scrolls or sewering
* untinkering a dictionary to get the bridge
* items in closet, if enabled
* free pulls from Hagnk's
* items in storage, if no longer under ronin/HC restrictions (note that all of the item is pulled, not just the amount requested)
* items in the clan stash, if enabled
* item creation, up to the quantity creatable from ingredients on hand (this can be overriden by a buyScript)
* trading worthless items to the Hermit
* trading yeti furs to the Tr4pz0r
* NPC purchase (if enabled), or Mall purchase (if enabled, and no ingredients on hand)
* budgeted pulls from storage
* item creation, unless buying the item is enabled and appears to be cheaper than the cost of acquiring all the ingredients
* one final attempt at Mall purchase, if enabled and everything else has failed
{{RFI|Are there exceptions to the info listed under Special?}}
{{RFI|Are there exceptions to the info listed under Special?}}
[[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?