Difference between revisions of "Add item condition"

From Kolmafia
Jump to navigation Jump to search
imported>Bale
(remove_item_condition is new in r9093)
imported>Eliteofdelete
Line 20: Line 20:
 
<p>Note that this function adds items in "+ mode" rather than the standard "total mode" done via the Adventuring pane of KoLmafia; ie it will add a condition to get {{pspan|qty}} additional items, rather than a condition to have {{pspan|qty}} total items in inventory.|
 
<p>Note that this function adds items in "+ mode" rather than the standard "total mode" done via the Adventuring pane of KoLmafia; ie it will add a condition to get {{pspan|qty}} additional items, rather than a condition to have {{pspan|qty}} total items in inventory.|
  
needscode=yes|
+
code1={{CodeSample|
 +
title=Code Samples|
 +
description=Adventures at the Castle in the Sky Top Floor until you get the semi-rare or run out of adventures.|
 +
code=
 +
<syntaxhighlight>
 +
if (get_property("semirareLocation") == "The Castle in the Clouds in the Sky (Top Floor)")
 +
  abort("Your last semi rare was Mick's IcyVapoHotness Inhaler, you can't get it again.");
 +
add_item_condition(1, $item[Mick's IcyVapoHotness Inhaler]);
 +
int current = item_amount($item[Mick's IcyVapoHotness Inhaler]);
 +
adventure(my_adventures(), $location[The Castle in the Clouds in the Sky (Top Floor)]);
 +
if (item_amount($item[Mick's IcyVapoHotness Inhaler]) > current)
 +
  print("We found the Inhaler!", "green");
 +
else print("We failed to get the Inhaler :(", "red");
 +
</syntaxhighlight>|
 +
}}|
  
 
see_also={{SeeAlso|adventure|is_goal|remove_item_condition}}|
 
see_also={{SeeAlso|adventure|is_goal|remove_item_condition}}|

Revision as of 08:21, 11 January 2015

Function Syntax

void add_item_condition(int qty ,item want )

  • qty is the desired quantity
  • want is the desired item

Adds qty of want to your current adventuring conditions. Auto-adventuring through KoLmafia or the adventure() function will stop if your current conditions are met.

Note that this function adds items in "+ mode" rather than the standard "total mode" done via the Adventuring pane of KoLmafia; ie it will add a condition to get qty additional items, rather than a condition to have qty total items in inventory.

Code Samples

Adventures at the Castle in the Sky Top Floor until you get the semi-rare or run out of adventures.

if (get_property("semirareLocation") == "The Castle in the Clouds in the Sky (Top Floor)")
   abort("Your last semi rare was Mick's IcyVapoHotness Inhaler, you can't get it again.");
add_item_condition(1, $item[Mick's IcyVapoHotness Inhaler]);
int current = item_amount($item[Mick's IcyVapoHotness Inhaler]);
adventure(my_adventures(), $location[The Castle in the Clouds in the Sky (Top Floor)]);
if (item_amount($item[Mick's IcyVapoHotness Inhaler]) > current)
   print("We found the Inhaler!", "green");
else print("We failed to get the Inhaler :(", "red");

CLI Equivalent

The CLI command "condition" offers similar functionality.

See Also

adventure() | is_goal() | remove_item_condition()