diff --git a/oregen-manager.lua b/oregen-manager.lua index 9a74d32..1719662 100644 --- a/oregen-manager.lua +++ b/oregen-manager.lua @@ -251,8 +251,10 @@ function getNumCraftable (ingredients, current_stock) return result end -function adjustStock (current_stock, recipe, count) - for _, ingredient in ipairs(recipe.ingredients) do +function adjustStock (current_stock, ingredients, count) + if count == 0 then return end + local item, i_count + for _, ingredient in ipairs(ingredients) do item, i_count = ingredient[1], ingredient[2] current_stock[item] = current_stock[item] - (i_count * count) end @@ -263,7 +265,7 @@ function craftRecipe (ticker, recipe, current_stock) if recipe.limit ~= nil then count = math.min(count, recipe.limit) end - adjustStock(current_stock, recipe, count) + adjustStock(current_stock, recipe.ingredients, count) local createRequest createRequest = function (recipe, i) if i == nil then i = 1 end