up
This commit is contained in:
parent
6cea7016d0
commit
eecaa14693
1 changed files with 21 additions and 19 deletions
|
@ -282,27 +282,29 @@ function add_product(recipe, product)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function util.replace_ingredient_add_to(recipe_name, old, new)
|
-- Get the amount of the result, will check base/normal not expensive
|
||||||
if me.bypass[recipe_name] then return end
|
function util.get_amount(recipe_name, product)
|
||||||
if data.raw.recipe[recipe_name] and (data.raw.item[new] or data.raw.fluid[new]) then
|
if not product then product = recipe_name end
|
||||||
me.add_modified(recipe_name)
|
local recipe = data.raw.recipe[recipe_name]
|
||||||
replace_ingredient_add_to(data.raw.recipe[recipe_name], old, new)
|
if recipe then
|
||||||
replace_ingredient_add_to(data.raw.recipe[recipe_name].normal, old, new)
|
if recipe.normal and recipe.normal.results then
|
||||||
replace_ingredient_add_to(data.raw.recipe[recipe_name].expensive, old, new)
|
for i, result in pairs(recipe.normal.results) do
|
||||||
|
if result[1] == product then return result[2] end
|
||||||
|
if result.name == product then return result.amount end
|
||||||
end
|
end
|
||||||
end
|
elseif recipe.normal and recipe.normal.result_count then
|
||||||
|
return recipe.normal.result_count
|
||||||
function replace_ingredient_add_to(recipe, old, new)
|
elseif recipe.results then
|
||||||
if recipe ~= nil and recipe.ingredients ~= nil then
|
for i, result in pairs(recipe.results) do
|
||||||
for i, existing in pairs(recipe.ingredients) do
|
if result[1] == product then return result[2] end
|
||||||
if existing[1] == new or existing.name == new then
|
if result.name == product then return result.amount end
|
||||||
add_to_ingredient(recipe, new, existing[2] and existing[2] or existing.amount)
|
|
||||||
remove_ingredient(recipe, old)
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
elseif recipe.result_count then
|
||||||
|
return recipe.result_count
|
||||||
end
|
end
|
||||||
replace_ingredient(recipe, old, new)
|
return 1
|
||||||
end
|
end
|
||||||
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Replace one ingredient with another in a recipe
|
-- Replace one ingredient with another in a recipe
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue