Add item condition: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Bale
see also
Convert to Template:Function2 format
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{
<onlyinclude>{{{{{format|Function2}}}
#vardefine:name|add_item_condition}}{{
|name=add_item_condition
#vardefine:return_type|void}}{{
|function1.return_type=void
|function1.description=
|function1.param1=qty
|function1.param1.type=int
|function1.param1.description=Desired quantity
|function1.param2=want
|function1.param2.type=item
|function1.param2.description=Desired item
|function2.return_type=void
|function2.description=Adds a number of the given item to the current auto-adventuring conditions.
|function2.param1=want
|function2.param1.type=item
|function2.param1.description=Desired item
|function2.param2=qty
|function2.param2.type=int
|function2.param2.description=Desired quantity
|description=Adds {{pspan|qty}} of {{pspan|want}} to your current adventuring conditions. Auto-adventuring through KoLmafia or the [[adventure|adventure()]] function will stop if your current conditions are met.</p>


FunctionPage|
<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>
name={{#var:name}}|
function_category=Adventuring|


function1={{Function|
<p>The second form (item, quantity) was added in [https://kolmafia.us/threads/20000-add-more-method-chaining-variants-of-ash-functions-where-the-object-you-are.24859/ r20000].</p>
name={{#var:name}}|
|code1={{CodeSample|
aggregate={{#var:aggregate}}|
  |title=Code Samples
return_type={{#var:return_type}}|
  |description=Adventures at the Castle in the Sky Top Floor until you get the semi-rare or run out of adventures.
return_also={{#var:return_also}}|
  |code=
parameter1={{Param|int|qty}}|
<syntaxhighlight lang="d">
parameter2={{Param|item|want}}|
if ( get_property("semirareLocation") == "The Castle in the Clouds in the Sky (Top Floor)" )
p1desc={{pspan|qty}} is the desired quantity|
{
p2desc={{pspan|want}} is the desired item|
  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 ] );
function_description=Adds {{pspan|qty}} of {{pspan|want}} to your current adventuring conditions. Auto-adventuring through KoLmafia or the [[adventure|adventure()]] function will stop if your current conditions are met.</p>
int current = item_amount( $item[ Mick's IcyVapoHotness Inhaler ] );
<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.|
adventure( my_adventures(), $location[ The Castle in the Clouds in the Sky (Top Floor) ] );
 
if ( item_amount( $item[ Mick's IcyVapoHotness Inhaler] ) > current )
needscode=yes|
{
  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}}
|cli_equiv=The CLI command "condition" offers similar functionality.
}}</onlyinclude>


see_also={{SeeAlso|adventure|is_goal}}|
[[Category:Adventuring]]
cli_equiv=The CLI command "condition" offers similar functionality.|
}}

Latest revision as of 13:49, 23 December 2020

Function Syntax

void add_item_conditionint qty, item want )

  • qty: Desired quantity
  • want: Desired item

void add_item_conditionitem want, int qty )

Adds a number of the given item to the current auto-adventuring conditions.
  • want: Desired item
  • qty: Desired quantity

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.

The second form (item, quantity) was added in r20000.

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