Overdrink: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Eliteofdelete
Code Example
Remove function1.description since it's redundant with function2.description
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{
<onlyinclude>{{{{{format|Function2}}}
#vardefine:name|overdrink}}{{
|name=overdrink
#vardefine:return_type|boolean}}{{
|function1.return_type=boolean
|function1.description=
|function1.param1=qty
|function1.param1.type=int
|function1.param1.description=Quantity of item to drink
|function1.param2=consume
|function1.param2.type=item
|function1.param2.optional=
|function1.param2.default=
|function1.param2.description=Item to drink
|function2.return_type=boolean
|function2.description=Attempts to drink a given number of item(s), suppressing overdrinking warnings.
|function2.param1=consume
|function2.param1.type=item
|function2.param1.description=Item to drink
|function2.param2=qty
|function2.param2.type=int
|function2.param2.optional=yes
|function2.param2.default=1
|function2.param2.description=Quantity of item to drink
|description=<p>Attempts to drink {{pspan|qty}} amount of item {{pspan|consume}}. Returns <code>true</code> for drinkable items and <code>false</code> for others. (The return value does not reflect whether or not the items were actually consumed.)</p>


FunctionPage|
<p>Using this command, rather than {{f|drink}}, suppresses warning dialogs for overdrinking and drinking without Ode to Booze.</p>
name={{#var:name}}|


function1={{Function|
<p>The second form (item, quantity) was added in [https://kolmafia.us/threads/19548-add-method-chaining-variants-for-ash-functions-overdrink-retrieve_item-buy.24218/ r19548].</p>
name={{#var:name}}|
|code1={{CodeSample
aggregate={{#var:aggregate}}|
  |title=Code Samples
return_type={{#var:return_type}}|
  |description=This will drink 1 Mae West without Ode without a warning if you are unable to get Ode.
return_also={{#var:return_also}}|
  |code=
parameter1={{Param|int|qty}}|
<syntaxhighlight lang="d">
parameter2={{Param|item|consume}}|
if ( !have_skill( $skill[ The Ode to Booze ] ) && !can_interact() )
p1desc={{Pspan|qty}} is the quantity to drink|
{
p2desc={{Pspan|consume}} is the item to drink|
  // Make sure we are not over drinking with the Mea West
}}|
   if ( inebriety_limit() >= my_inebriety() + 4 ) {
 
       print( "You don't have Ode and can't get it, drinking Mae West anyways." );
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.) Using this command, rather than {{f|drink}}, suppresses warning dialogs for overdrinking and drinking without Ode to Booze.|
       overdrink( 1, $item[ Mae West ] ); // Overdrink Prevents Ode Warning
 
  }
code1={{CodeSample|
  else
title=Code Samples|
  {
description=This will drink Mae West without Ode without a warning if you are unable to get Ode.|
      print( "You do not have enough inebriety left to prevent overdrunkeness" );
code=
<syntaxhighlight>
if (!have_skill($skill[The Ode to Booze]) && !can_interact()) {
   if (inebriety_limit() >= my_inebriety()+4) { //Make sure we are not over drinking with the Mea West
       print("You don't have Ode and can't get it, drinking Mae West anyways.");
       overdrink(1, $item[Mae West]); //Overdrink Prevents Ode Warning
   }
   }
  else print("You do not have enough inebriety left to prevent overdrunkeness");
}
else
else print("You should cast or acquire the Ode Buff before drinking.");  
{
</syntaxhighlight>|
  print( "You should cast or acquire the Ode Buff before drinking." );
moreinfo=
}
Checks to see if you have Ode and that you can't get it from a buff bot. Then it drinks it "silently" after making sure it won't overdrink off of it.
</syntaxhighlight>
}}|
  |moreinfo=Beware: Since it suppresses the overdrink warning, it is wise to do checks to assure you don't accidentally overdrink when using it to prevent the Ode Warning.
 
see_also={{SeeAlso|can_drink|drink|inebriety_limit|my_inebriety}}|
cli_equiv=The CLI command "drink" works similarly.|
}}
}}
 
|see_also={{SeeAlso|can_drink|drink|inebriety_limit|my_inebriety}}
|cli_equiv=The CLI command "drink" works similarly.
}}</onlyinclude>
[[Category:Item Management]]
[[Category:Item Management]]

Latest revision as of 14:21, 23 December 2020

Function Syntax

boolean overdrinkint qty, item consume )

  • qty: Quantity of item to drink
  • consume: Item to drink

boolean overdrinkitem consume, int? qty = 1 )

Attempts to drink a given number of item(s), suppressing overdrinking warnings.
  • consume: Item to drink
  • qty: Quantity of item to drink

Attempts to drink qty amount of item consume. Returns true for drinkable items and false for others. (The return value does not reflect whether or not the items were actually consumed.)

Using this command, rather than drink(), suppresses warning dialogs for overdrinking and drinking without Ode to Booze.

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

Code Samples

This will drink 1 Mae West without Ode without a warning if you are unable to get Ode.

if ( !have_skill( $skill[ The Ode to Booze ] ) && !can_interact() )
{
   // Make sure we are not over drinking with the Mea West
   if ( inebriety_limit() >= my_inebriety() + 4 ) {
      print( "You don't have Ode and can't get it, drinking Mae West anyways." );
      overdrink( 1, $item[ Mae West ] ); // Overdrink Prevents Ode Warning
   }
   else
   {
      print( "You do not have enough inebriety left to prevent overdrunkeness" );
   }
}
else
{
   print( "You should cast or acquire the Ode Buff before drinking." );
}

Beware: Since it suppresses the overdrink warning, it is wise to do checks to assure you don't accidentally overdrink when using it to prevent the Ode Warning.

CLI Equivalent

The CLI command "drink" works similarly.

See Also

can_drink() | drink() | inebriety_limit() | my_inebriety()