Creatable amount

From Kolmafia
Revision as of 20:15, 9 May 2009 by imported>MapleMario (New page: '''int creatable_amount( item it )''' <br />Returns the amount of the item that you are capable of creating with your current inventory and skills. <p>Example: <br /><pre># end-of-ascens...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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;

}