fix: remove syntax and logic errors
This commit is contained in:
parent
04f6d66e56
commit
192f33c823
1 changed files with 5 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue