Creatable amount

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

int creatable_amount( item it )
Returns the amount of the item that you are capable of creating with your current inventory and skills.

Example:

# end-of-ascension scriptlet that tries to create your key lime pies
boolean create_key_lime_pies()
{

  item[int] pies;
  pies[0] = $item[boris's key lime pie];
  pies[1] = $item[jarlsberg's key lime pie];
  pies[2] = $item[sneaky pete's key lime pie];
  pies[3] = $item[digital key lime pie];
  pies[4] = $item[star key lime pie];

  boolean ret = true;

  foreach i in pies
  {

    if (item_amount(pies[i]) < 1)
    {
      
      if (creatable_amount(pies[i]) >= 1)
      {
        
        if (!create(1, pies[i])) ret = false;
        
      }
      else
      {
      
        ret = false;
      
      }
      
    }

  }

  return ret;

}