milo: crafting fixes
This commit is contained in:
@@ -56,7 +56,7 @@ local function getCraftingTool(storage, item)
|
|||||||
return item
|
return item
|
||||||
end
|
end
|
||||||
|
|
||||||
function Craft.ingedients(recipe)
|
function Craft.ingredients(recipe)
|
||||||
local i = 0
|
local i = 0
|
||||||
local keys = Util.keys(recipe.ingredients)
|
local keys = Util.keys(recipe.ingredients)
|
||||||
return function()
|
return function()
|
||||||
@@ -297,7 +297,16 @@ function Craft.craftRecipeInternal(recipe, count, storage, origItem, path)
|
|||||||
count = canCraft
|
count = canCraft
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function maxBatch()
|
||||||
|
local max = 64
|
||||||
|
for _, i in Craft.ingredients(recipe) do
|
||||||
|
max = math.min(max, math.floor(64 / i.count))
|
||||||
|
end
|
||||||
|
return max
|
||||||
|
end
|
||||||
|
|
||||||
local maxCount = recipe.maxCount or math.floor(64 / recipe.count)
|
local maxCount = recipe.maxCount or math.floor(64 / recipe.count)
|
||||||
|
maxCount = math.min(maxCount, maxBatch())
|
||||||
|
|
||||||
repeat
|
repeat
|
||||||
local craftedIngredient
|
local craftedIngredient
|
||||||
@@ -463,8 +472,7 @@ function Craft.getCraftableAmount(inRecipe, inCount, items, missing)
|
|||||||
local canCraft = 0
|
local canCraft = 0
|
||||||
|
|
||||||
for _ = 1, count do
|
for _ = 1, count do
|
||||||
for _,entry in pairs(recipe.ingredients) do
|
for _, item in Craft.ingredients(recipe) do
|
||||||
local item = convert(entry)
|
|
||||||
local summedItem = summedItems[item.key] or Craft.getItemCount(items, item.key)
|
local summedItem = summedItems[item.key] or Craft.getItemCount(items, item.key)
|
||||||
|
|
||||||
local irecipe = findValidRecipe(item.key, path)
|
local irecipe = findValidRecipe(item.key, path)
|
||||||
|
|||||||
@@ -37,9 +37,7 @@ function recipeTab:setItem(item)
|
|||||||
|
|
||||||
local t = { }
|
local t = { }
|
||||||
if self.recipe then
|
if self.recipe then
|
||||||
for k, v in Craft.ingedients(self.recipe) do
|
for k, v in Craft.ingredients(self.recipe) do
|
||||||
_syslog(k)
|
|
||||||
_syslog(v)
|
|
||||||
table.insert(t, {
|
table.insert(t, {
|
||||||
slot = k,
|
slot = k,
|
||||||
key = v.key,
|
key = v.key,
|
||||||
|
|||||||
Reference in New Issue
Block a user