recipe.ingredients
Posted: Sun Jun 18, 2017 3:26 am
Hi I have a some problem.
I add a new science pack recipes, and add new ingredients array with table.insert.
But this is change original science pack recipes
Could you tell me why the problem occurred??
I add a new science pack recipes, and add new ingredients array with table.insert.
But this is change original science pack recipes
Code: Select all
local item_name = "iron-plate"
local scipack_container = {"science-pack-1", "science-pack-2", "science-pack-3", "military-science-pack", "production-science-pack", "high-tech-science-pack"}
for _, recipe in pairs (data.raw["recipe"]) do
if string.find(recipe.name, "-pack") then
for i = 1, #scipack_container do
if recipe.name == scipack_container[i] then
data:extend({
sp_recipe{
name = "AA_"..recipe.name,
energy_required = recipe.energy_required * 2,
order = i.."-alien-science-"..scipack_container[i],
icon = "__Additional-Alien__/graphics/icon/"..recipe.name..".png",
ingredients = recipe.ingredients,
results = {{type = "item", name = recipe.name, amount = 3}}
}
})
table.insert(data.raw.recipe["AA_"..recipe.name].ingredients, 1, {item_name, i*5})
-- table.insert(data.raw.recipe[scipack_container[i]].ingredients, 1, {item_name, i*5})
-- table.remove(data.raw.recipe[scipack_container[i]].ingredients, 1)
end
end
end
end
Could you tell me why the problem occurred??