Page 1 of 1

[SOLVED] Migrations

Posted: Fri Jun 17, 2016 5:22 pm
by DRY411S
I've been asked if my mod for Recycling could be changed so that it can be added to previously saved worlds.

I think that means that I have to write a migration script, or an on_load script.

All my code is in the data phase and modifies (adds to) data.raw

I know the on_load doesn't expose data.raw. I think migrations phase doesn't either.

Is it possible in migrations or on_load to add to game.player.recipes (for example) or has it become read-only by then?

Re: Migrations

Posted: Fri Jun 17, 2016 5:37 pm
by orzelek
Take a look at bobslogistics mod migration.
They are doing exactly what you need - there is a techa nd recipe reset to make sure recipes and tech costs are updated and new ones are added in.
There is also section that checks for already researched technologies and enables recipes as needed.

Re: Migrations

Posted: Fri Jun 17, 2016 6:09 pm
by DRY411S
orzelek wrote:Take a look at bobslogistics mod migration.
They are doing exactly what you need - there is a techa nd recipe reset to make sure recipes and tech costs are updated and new ones are added in.
There is also section that checks for already researched technologies and enables recipes as needed.
Thanks I had looked at mods like that. I've found lots of examples of reset_recipes and reset_technologies. Do these force factorio to reload from all the mod data.luas? The documentation and wiki aren't clear about this. Or at least they aren't clear to me. :oops:

Re: Migrations

Posted: Fri Jun 17, 2016 7:12 pm
by orzelek
DRY411S wrote:
orzelek wrote:Take a look at bobslogistics mod migration.
They are doing exactly what you need - there is a techa nd recipe reset to make sure recipes and tech costs are updated and new ones are added in.
There is also section that checks for already researched technologies and enables recipes as needed.
Thanks I had looked at mods like that. I've found lots of examples of reset_recipes and reset_technologies. Do these force factorio to reload from all the mod data.luas? The documentation and wiki aren't clear about this. Or at least they aren't clear to me. :oops:
Thats correct. Techs and recipes are stored in save so they need to be refreshed if data.raw has been changed by mods.

Re: Migrations

Posted: Fri Jun 17, 2016 8:16 pm
by DRY411S
orzelek wrote: Thats correct. Techs and recipes are stored in save so they need to be refreshed if data.raw has been changed by mods.
Got it. Thanks. :)