Eat

From Kolmafia
Revision as of 22:05, 2 March 2010 by imported>StDoodle (moved Eat() to Eat)
Jump to navigation Jump to search

boolean eat(int quantity, item itemtype)

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.

So,

 eat(3,$item[stinky hi mein]);


will eat 3 stinky hi meins (depending on fullness) and return true.

While,

 eat(3,$item[blue pixel]);


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:

 boolean eat_hi_mein()
 {
     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;
 }

This code uses item_amount(), fullness_limit() and my_fullness() to pre-empt problems that may occur.