I managed to frankenstein this code and it works.
-- Add byproducts
data.raw.recipe["edrill-0to1"].main_product="electric-mining-drill"
data.raw.recipe["edrill-0to1"].results={{name="electric-mining-drill",probability=1,amount=1},{name="iron-dust",probability=0.4,amount=1}}
local recipes ...
Search found 3 matches
- Thu Feb 08, 2024 4:07 am
- Forum: Modding help
- Topic: Need help with mass adding byproducts to recipes with a certain item
- Replies: 7
- Views: 1195
- Mon Feb 05, 2024 5:04 pm
- Forum: Modding help
- Topic: Need help with mass adding byproducts to recipes with a certain item
- Replies: 7
- Views: 1195
Re: Need help with mass adding byproducts to recipes with a certain item
Basically, you'd need 2 loops: one running over all recipes, and then another inside of that running over the ingredients looking for and changing as needed.
for name, recipe in pairs(data.raw.recipe) do
for k, ingredient in pairs(recipe.ingredients) do
-- do stuff
end
end
You can work ...
- Mon Feb 05, 2024 1:09 pm
- Forum: Modding help
- Topic: Need help with mass adding byproducts to recipes with a certain item
- Replies: 7
- Views: 1195
Need help with mass adding byproducts to recipes with a certain item
I know you can do it like this manually, but I would like to turn this into a loop that will find all ingredients and use table.insert to add the byproduct instead.
data.raw.recipe["iron-gear-wheel"].ingredients =
{
{"iron-plate", 2},
{"iron-plate-scrap", 1}
}
Please help :cry:, I don't wanna ...
data.raw.recipe["iron-gear-wheel"].ingredients =
{
{"iron-plate", 2},
{"iron-plate-scrap", 1}
}
Please help :cry:, I don't wanna ...