In my mod, I have a function that doubles the ingredient cost of science packs.
I currently know the ingredients used, so the function I use looks like this:
function ChangeRecipe(Name, Ingredient1, Ingredient2, Amount)
for k, v in pairs(data.raw["recipe"][Name].ingredients) do
if v[1] == Ingredient1 then table.remove(data.raw["recipe"][Name].ingredients, k) end
end
table.insert(data.raw["recipe"][Name].ingredients,{Ingredient2, Amount})
end
if NEConfig.mod.DyTechCore then
ChangeRecipe("science-pack-1", "stone-gear-wheel", "stone-gear-wheel", 2)
end
if not NEConfig.mod.DyTechCore then
ChangeRecipe("science-pack-1", "iron-gear-wheel", "iron-gear-wheel", 2)
end
ChangeRecipe("science-pack-1", "copper-plate", "copper-plate", 2)
ChangeRecipe("science-pack-2", "basic-transport-belt", "basic-transport-belt", 2)
ChangeRecipe("science-pack-2", "basic-inserter", "basic-inserter", 2)
ChangeRecipe("science-pack-3", "advanced-circuit", "advanced-circuit", 2)
ChangeRecipe("science-pack-3", "smart-inserter", "smart-inserter", 2)
ChangeRecipe("science-pack-3", "battery", "battery", 2)
ChangeRecipe("science-pack-3", "steel-plate", "steel-plate", 2)
ChangeRecipe("alien-science-pack", "alien-artifact", "alien-artifact", 2)
This caused an incompatibility with science overhaul mod, since it changed the ingredients used for science packs.
How can I just say, take whatever the ingredients are and double it. (Without specifying what the ingredients are?)
for _, recipe in pairs({"science-pack-1", "science-pack-2", "science-pack-3", "alien-science-pack"}) do
for _, ingredient in pairs(data.raw.recipe[recipe].ingredients) do
ingredient[2] = ingredient[2] * 2
end
end