Drink: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
mNo edit summary
 
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{
<onlyinclude>{{{{{format|Function2}}}
#vardefine:name|drink}}{{
|name=drink
#vardefine:return_type|boolean}}{{
|function1.return_type=boolean
|function1.description=Attempts to drink the {{pspan|booze}} item(s).
|function1.param1=booze
|function1.param1.type=item
|function1.param1.description=Item to drink
|function1.param2=qty
|function1.param2.type=int
|function1.param2.description=Amount to drink
|function1.param2.optional=yes
|function1.param2.default=1
|function2.return_type=boolean
|function2.description=Attempts to drink {{pspan|qty}} of {{pspan|booze}}.
|function2.param1=qty
|function2.param1.type=int
|function2.param1.description=Amount to drink
|function2.param2=booze
|function2.param2.type=item
|function2.param2.description=Item to drink
|description=<p>Attempts to drink {{pspan|qty}} amount of the {{pspan|booze}} item. Returns <code>true</code> for drinkable 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 "drink" drink helper items (e.g. {{kolwiki|divine champagne flute}}) to queue them before drinking the actual booze item. Drink helpers can be identified with {{f|item_type}}, which returns <code>"drink helper"</code> for such items. To cancel all queued drink helpers, call {{f|clear_booze_helper}}.</p>
name={{#var:name}}|
function_category=Item Management|


function1={{Function|
<p>If this command will cause you to overdrink, KoLmafia will show a warning dialog. Using this command without Ode to Booze active will also show a warning, if you have the skill and the MP required to cast it.</p>
name={{#var:name}}|
|code1={{CodeSample|
aggregate={{#var:aggregate}}|
  title=Code Sample|
return_type={{#var:return_type}}|
  description=Drinks as many tangaritas as possible without getting drunk.|
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 drink|
{{!}}
p2desc={{Pspan|consume}} is the item to drink|
<syntaxhighlight lang="d" line highlight="2">
}}|
int amount = floor((inebriety_limit() - my_inebriety()) / 4);
drink(amount, $item[tangarita]);
</syntaxhighlight>
{{!}}
<syntaxhighlight lang="javascript" line highlight="4">
const { drink, inebrietyLimit, myInebriety } = require("kolmafia");


function_description=Will attempt to drink {{pspan|qty}} amount of item {{pspan|consume}}. Returns true for drinkable items and false for items that are not. (The return value does not reflect whether or not the items were actually consumed.) If this command will cause you to overdrink, a warning dialog will be given. Using this command without Ode to Booze active, when you have the skill & required MP to cast it, will give a warning about drinking without Ode.|
const amount = Math.floor((inebrietyLimit() - myInebriety()) / 4);
 
drink(amount, Item.get('tangarita'));
needscode=yes|
</syntaxhighlight>
 
{{!}}}
see_also={{SeeAlso|can_drink|drink_silent|inebriety_limit|my_inebriety}}|
}}
cli_equiv=The CLI command "drink" works similarly.|
|cli_equiv=The CLI command <code>drink</code> works similarly.
|see_also={{SeeAlso/Booze Management}}
}}
}}
</onlyinclude>
[[Category:Item Management]]

Latest revision as of 14:33, 13 July 2021

Function Syntax

boolean drinkitem booze, int? qty = 1 )

Attempts to drink the booze item(s).
  • booze: Item to drink
  • qty: Amount to drink

boolean drinkint qty, item booze )

Attempts to drink qty of booze.
  • qty: Amount to drink
  • booze: Item to drink

Attempts to drink qty amount of the booze item. Returns true for drinkable 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 "drink" drink helper items (e.g. divine champagne flute) to queue them before drinking the actual booze item. Drink helpers can be identified with item_type(), which returns "drink helper" for such items. To cancel all queued drink helpers, call clear_booze_helper().

If this command will cause you to overdrink, KoLmafia will show a warning dialog. Using this command without Ode to Booze active will also show a warning, if you have the skill and the MP required to cast it.

Code Sample

Drinks as many tangaritas as possible without getting drunk.

ASH JavaScript
int amount = floor((inebriety_limit() - my_inebriety()) / 4);
drink(amount, $item[tangarita]);
const { drink, inebrietyLimit, myInebriety } = require("kolmafia");

const amount = Math.floor((inebrietyLimit() - myInebriety()) / 4);
drink(amount, Item.get('tangarita'));

CLI Equivalent

The CLI command drink works similarly.

See Also

can_drink() | clear_booze_helper() | drink() | drinksilent() | overdrink()