Retrieve price: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
Created page with "{{ #vardefine:name|retrieve_price}}{{ #vardefine:return_type|int}}{{ FunctionPage| name={{#var:name}}| function1={{Function| name={{#var:name}}| aggregate={{#var:aggregate}}..."
 
Mcroft (talk | contribs)
No edit summary
 
(2 intermediate revisions by one other user not shown)
Line 63: Line 63:
}}|
}}|


function_description=Returns the total meat cost of using [[retrieve_item]]. This does include the mall value of items you already own.|
function_description=Returns the meat worth of item or items. This shares some code with [[retrieve_item]]. It does include the value of items you already own. To determine the value of items you own it uses valueOfInventory preference.<br>
0.0 - Items already in inventory are considered free.<br>
1.0 - Items are valued at their autosell price.<br>
2.0 - Items are valued at current Mall price, unless they are min-priced.<br>
3.0 - Items are always valued at Mall price (not really realistic).<br>
Values in between are interpolated. The default value is 1.8.
 
If an item is not buyable, this function will return MAXINT, or 2^63-1.
|


code1={{CodeSample|
code1={{CodeSample|
Line 72: Line 80:
int price = retrieve_price(nightcap);
int price = retrieve_price(nightcap);
if(price > 30000)
if(price > 30000)
   abort( nightcap+ " is unreasonably expensive. It costs " +price );
   abort( nightcap+ " is unreasonably expensive, it will be a waste to use it. It is worth " +price );
if(my_inebriety() == inebriety_limit())
if(my_inebriety() == inebriety_limit())
{
{

Latest revision as of 04:07, 25 April 2023

Function Syntax

int retrieve_price(item get )

  • get is the item to acquire

int retrieve_price(item get ,int qty )

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

int retrieve_price(int qty ,item get )

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

int retrieve_price(item get ,int qty ,boolean exact )

  • get is the item to acquire
  • qty is the quantity to acquire
  • exact if true will perform new mallsearch to make sure the price is exact

int retrieve_price(int qty ,item get ,boolean exact )

  • qty is the quantity to acquire
  • get is the item to acquire
  • exact if true will perform new mallsearch to make sure the price is exact

Returns the meat worth of item or items. This shares some code with retrieve_item. It does include the value of items you already own. To determine the value of items you own it uses valueOfInventory preference.
0.0 - Items already in inventory are considered free.
1.0 - Items are valued at their autosell price.
2.0 - Items are valued at current Mall price, unless they are min-priced.
3.0 - Items are always valued at Mall price (not really realistic).
Values in between are interpolated. The default value is 1.8. If an item is not buyable, this function will return MAXINT, or 2^63-1.

Code Sample

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

item nightcap = $item[ Mon Tiki ];
int price = retrieve_price(nightcap);
if(price > 30000)
  abort( nightcap+ " is unreasonably expensive, it will be a waste to use it. It is worth " +price );
if(my_inebriety() == inebriety_limit())
{
   if ( !retrieve_item( nightcap ) )
      abort( "Could not make/buy a " + nightcap + " for a nightcap." );
   else
      overdrink( 1 , nightcap );
}

CLI Equivalent

?

See Also

retrieve_item() | buy()