Eat: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
mNo edit summary
 
(4 intermediate revisions by 3 users not shown)
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}}|
function_category=Item Management|


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">
}}|
int amount = (fullness_limit() - my_fullness()) / 3;
eat(amount, $item[olive lo mein]);
</syntaxhighlight>
{{!}}
<syntaxhighlight lang="javascript" line highlight="4">
const { eat, fullnessLimit, myFullness } = require("kolmafia");


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.|
const amount = Math.floor((fullnessLimit() - myFullness()) / 4);
 
drink(amount, Item.get('olive lo mein'));
needscode=yes|
</syntaxhighlight>
 
{{!}}}
see_also={{SeeAlso|can_eat|eat_silent|fullness_limit|my_fullness}}|
}}
cli_equiv=The CLI command "eat" works similarly.|
|cli_equiv=The CLI command <code>eat</code> works similarly.
|see_also={{SeeAlso/Food Management}}
}}
}}
</onlyinclude>
[[Category:Item Management]]

Latest revision as of 14:32, 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
int amount = (fullness_limit() - my_fullness()) / 3;
eat(amount, $item[olive lo mein]);
const { eat, fullnessLimit, myFullness } = require("kolmafia");

const amount = Math.floor((fullnessLimit() - myFullness()) / 4);
drink(amount, Item.get('olive lo mein'));

CLI Equivalent

The CLI command eat works similarly.

See Also

can_eat() | clear_food_helper() | eat() | eatsilent()