Page 1 of 1

Including new recipe on vanilla tech when it's already researched

Posted: Sun Jul 18, 2021 9:56 pm
by Chess
I'm creating a mod with a new combinator that interacts with trains and I'd like to unlock it with the vanilla "circuit-network" technology. This is how I do it:

technology.lua

Code: Select all

table.insert(data.raw["technology"]["circuit-network"].effects, {type = "unlock-recipe",recipe = "train-requests-reader"})
But it doesn't work in saves that already researched that technology. How can I fix that?

Thank you.

Re: Including new recipe on vanilla tech when it's already researched

Posted: Sun Jul 18, 2021 10:12 pm
by Pi-C
Chess wrote: Sun Jul 18, 2021 9:56 pm I'm creating a mod with a new combinator that interacts with trains and I'd like to unlock it with the vanilla "circuit-network" technology. …
But it doesn't work in saves that already researched that technology. How can I fix that?
If your mod was added to an existing game, script.on_init will be triggered for your mod. Just add this to your event handler:

Code: Select all

for _, force in pairs(game.forces) do
  force.reset_technology_effects()
end

Re: Including new recipe on vanilla tech when it's already researched

Posted: Mon Jul 19, 2021 4:50 pm
by Chess
It worked, thank you! :D