Difference between revisions of "Eat"

From Kolmafia
Jump to navigation Jump to search
imported>Bale
m
(Rewrite page to use Template:Function2. Also add info on clear_food_helper().)
Line 1: Line 1:
{{
+
<onlyinclude>{{{{{format|Function2}}}
#vardefine:name|eat}}{{
+
|name=eat
#vardefine:return_type|boolean}}{{
+
|function1.return_type=boolean
 +
|function1.description=Attempts to eat the {{pspan|food}} item(s).
 +
|function1.param1=food
 +
|function1.param1.type=item
 +
|function1.param1.description=Item to eat
 +
|function1.param2=qty
 +
|function1.param2.type=int
 +
|function1.param2.description=Amount to eat
 +
|function1.param2.optional=yes
 +
|function1.param2.default=1
 +
|function2.return_type=boolean
 +
|function2.description=Attempts to eat {{pspan|qty}} of {{pspan|item}}.
 +
|function2.param1=qty
 +
|function2.param1.type=int
 +
|function2.param1.description=Amount to eat
 +
|function2.param2=food
 +
|function2.param2.type=item
 +
|function2.param2.description=Item to eat
 +
|description=<p>Attempts to eat {{pspan|qty}} amount of the {{pspan|food}} item. Returns <code>true</code> for edible items and <code>false</code> for items that are not. (The return value does not reflect whether or not the items were actually consumed.)</p>
  
FunctionPage|
+
<p>You can also "eat" food helper items (e.g. {{kolwiki|Ol' Scratch's salad fork}}) to queue them before eating the actual food item. Food helpers can be identified with {{f|item_type}}, which returns <code>"food helper"</code> for such items. To cancel all queued food helpers, call {{f|clear_food_helper}}.</p>
name={{#var:name}}|
 
  
function1={{Function|
+
<p>If you can use {{kolwiki|milk of magnesium}} but haven't used one yet, this command will show a warning dialog.</p>
name={{#var:name}}|
+
|code1={{CodeSample|
aggregate={{#var:aggregate}}|
+
  title=Code Sample|
return_type={{#var:return_type}}|
+
  description=Eats as many olive lo meins as possible.|
return_also={{#var:return_also}}|
+
  code={{{!}} class="wikitable" style="margin: auto"
parameter1={{Param|int|qty}}|
+
! ASH !! JavaScript
parameter2={{Param|item|consume}}|
+
{{!}}-
p1desc={{Pspan|qty}} is the quantity to eat|
+
{{!}}
p2desc={{Pspan|consume}} is the item to eat|
+
<syntaxhighlight lang="d" line highlight="2">
}}|
 
 
 
function_description=Will attempt to eat {{pspan|qty}} amount of item {{pspan|consume}}. Returns true for food items and false for items that are not. (The return value does not reflect whether or not the items were actually consumed.) Using this command without Got Milk active, when you are currently capable of acquiring said effect, will issue a warning dialog about eating without Got Milk active.|
 
 
 
code1={{CodeSample|
 
title=Code Sample|
 
description=Eat maximum amount of olive lo meins.|
 
code=
 
<syntaxhighlight>
 
 
int amount = (fullness_limit() - my_fullness()) / 3;
 
int amount = (fullness_limit() - my_fullness()) / 3;
 
eat(amount, $item[olive lo mein]);
 
eat(amount, $item[olive lo mein]);
 
</syntaxhighlight>
 
</syntaxhighlight>
}}|
+
{{!}}
 +
<syntaxhighlight lang="javascript" line highlight="4">
 +
const { eat, fullnessLimit, myFullness } = require("kolmafia");
  
see_also={{SeeAlso|can_eat|eatsilent|fullness_limit|my_fullness}}|
+
const amount = Math.floor((fullnessLimit() - myFullness()) / 4);
cli_equiv=The CLI command "eat" works similarly.|
+
drink(amount, Item.get('olive lo mein'));
 +
</syntaxhighlight>
 +
{{!}}}
 
}}
 
}}
 
+
|cli_equiv=The CLI command <code>eat</code> works similarly.
 +
}}
 +
</onlyinclude>
 
[[Category:Item Management]]
 
[[Category:Item Management]]

Revision as of 14:16, 13 July 2021

Function Syntax

boolean eatitem food, int? qty = 1 )

Attempts to eat the food item(s).
  • food: Item to eat
  • qty: Amount to eat

boolean eatint qty, item food )

Attempts to eat qty of item.
  • qty: Amount to eat
  • food: Item to eat

Attempts to eat qty amount of the food item. Returns true for edible items and false for items that are not. (The return value does not reflect whether or not the items were actually consumed.)

You can also "eat" food helper items (e.g. Ol' Scratch's salad fork) to queue them before eating the actual food item. Food helpers can be identified with item_type(), which returns "food helper" for such items. To cancel all queued food helpers, call clear_food_helper().

If you can use milk of magnesium but haven't used one yet, this command will show a warning dialog.

Code Sample

Eats as many olive lo meins as possible.

ASH JavaScript
1 int amount = (fullness_limit() - my_fullness()) / 3;
2 eat(amount, $item[olive lo mein]);
1 const { eat, fullnessLimit, myFullness } = require("kolmafia");
2 
3 const amount = Math.floor((fullnessLimit() - myFullness()) / 4);
4 drink(amount, Item.get('olive lo mein'));

CLI Equivalent

The CLI command eat works similarly.