Eat: Difference between revisions
Jump to navigation
Jump to search
imported>Bale mNo edit summary |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
{{ | <onlyinclude>{{{{{format|Function2}}} | ||
|name=eat | |||
|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> | |||
<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> | |||
<p>If you can use {{kolwiki|milk of magnesium}} but haven't used one yet, this command will show a warning dialog.</p> | |||
|code1={{CodeSample| | |||
title=Code Sample| | |||
description=Eats as many olive lo meins as possible.| | |||
code={{{!}} class="wikitable" style="margin: auto" | |||
! ASH !! JavaScript | |||
{{!}}- | |||
{{!}} | |||
<syntaxhighlight lang="d" line highlight="2"> | |||
code1={{CodeSample| | |||
title=Code Sample| | |||
description= | |||
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"); | |||
const amount = Math.floor((fullnessLimit() - myFullness()) / 4); | |||
drink(amount, Item.get('olive lo mein')); | |||
</syntaxhighlight> | |||
{{!}}} | |||
}} | }} | ||
|cli_equiv=The CLI command <code>eat</code> works similarly. | |||
|see_also={{SeeAlso/Food Management}} | |||
}} | |||
</onlyinclude> | |||
[[Category:Item Management]] | [[Category:Item Management]] |
Latest revision as of 14:32, 13 July 2021
Function Syntax
boolean eat( item food, int? qty = 1 )
- Attempts to eat the food item(s).
- food: Item to eat
- qty: Amount to eat
boolean eat( int 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.