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
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
function adjustStock (current_stock, recipe, count)
|
function adjustStock (current_stock, ingredients, count)
|
||||||
for _, ingredient in ipairs(recipe.ingredients) do
|
if count == 0 then return end
|
||||||
|
local item, i_count
|
||||||
|
for _, ingredient in ipairs(ingredients) do
|
||||||
item, i_count = ingredient[1], ingredient[2]
|
item, i_count = ingredient[1], ingredient[2]
|
||||||
current_stock[item] = current_stock[item] - (i_count * count)
|
current_stock[item] = current_stock[item] - (i_count * count)
|
||||||
end
|
end
|
||||||
|
|
@ -263,7 +265,7 @@ function craftRecipe (ticker, recipe, current_stock)
|
||||||
if recipe.limit ~= nil then
|
if recipe.limit ~= nil then
|
||||||
count = math.min(count, recipe.limit)
|
count = math.min(count, recipe.limit)
|
||||||
end
|
end
|
||||||
adjustStock(current_stock, recipe, count)
|
adjustStock(current_stock, recipe.ingredients, count)
|
||||||
local createRequest
|
local createRequest
|
||||||
createRequest = function (recipe, i)
|
createRequest = function (recipe, i)
|
||||||
if i == nil then i = 1 end
|
if i == nil then i = 1 end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue