Difference between revisions of "Retrieve item"

From Kolmafia
Jump to navigation Jump to search
imported>PhilmASTErpLus
(Added code sample and removed needscode=yes.)
imported>PhilmASTErpLus
(Whoops, forgot to type rest of the code.)
Line 23: Line 23:
 
description=This is an example of a very simple aftercore logout script.|
 
description=This is an example of a very simple aftercore logout script.|
 
code=<syntaxhighlight>
 
code=<syntaxhighlight>
 +
item nightcap = $item[ Mon Tiki ];
 
while (my_inebriety() <= inebriety_limit())
 
while (my_inebriety() <= inebriety_limit())
 
{
 
{
   if ( !retrieve_item( 1 , $item[ Mon Tiki ] ) )
+
   if ( !retrieve_item( 1 , nightcap ) )
       abort( "Could not make/buy a nightcap." );
+
       abort( "Could not make/buy a " + nightcap + " for a nightcap." );
 +
  else
 +
      overdrink( 1 , nightcap );
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 18:07, 28 June 2010

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).


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?

|