Eat: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
m moved Eat() to Eat
imported>StDoodle
No edit summary
Line 1: Line 1:
'''[[boolean]] eat(int quantity, item itemtype)'''
{{#vardefine:name|eat}}
{{#vardefine:return_type|boolean}}


Will attempt to eat the number of food specified. The return value only tells you whether the item can be eaten, not if you have enough room for it.
{{FunctionPage|
name={{#var:name}}|
function_category=Item Management|


So,<br>
function1={{Function|
<code>
name={{#var:name}}|
  eat(3,$item[stinky hi mein]);
aggregate={{#var:aggregate}}|
</code>
return_type={{#var:return_type}}|
<br>
return_also={{#var:return_also}}|
will eat 3 stinky hi meins (depending on fullness) and return true.
parameter1={{Param|int|qty}}|
parameter2={{Param|item|consume}}|
p1desc={{Pspan|qty}} is the quantity to eat|
p2desc={{Pspan|consume}} is the item to eat|
}}|


While,
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.)|
<br>
<code>
  eat(3,$item[blue pixel]);
</code>
<br>
will tell you that a blue pixel cannot be consumed and return false.


This can be adapted for safer consumption by using code such as the following:
needscode=yes|


<code>
see_also={{SeeAlso|can_eat|fullness_limit|my_fullness}}|
  boolean eat_hi_mein()
cli_equiv=The CLI command "eat" works similarly.|
  {
}}
      if( item_amount( $item[stinky hi mein] ) >= 3 )
      {
          if( ( fullness_limit() - my_fullness() ) >= 15 )
          {
              eat( 3 , $item[stinky hi mein] );
              return true;
          }
          else
              print( "You are too full to eat all of those" );
      }
      else
          print( "You have fewer than three in your inventory" );
  return false;
  }
</code>
 
This code uses [[item_amount()]], [[fullness_limit()]] and [[my_fullness()]] to pre-empt problems that may occur.

Revision as of 18:33, 5 March 2010



needs(code_samples);

Function Syntax

boolean eat(int qty ,item consume )

  • qty is the quantity to eat
  • consume is the item to eat

Will attempt to eat qty amount of item 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.)

CLI Equivalent

The CLI command "eat" works similarly.

See Also

can_eat() | fullness_limit() | my_fullness()