[SOLVED] Migrations

Place to get help with not working mods / modding interface.
User avatar
DRY411S
Filter Inserter
Filter Inserter
Posts: 736
Joined: Sun Mar 13, 2016 9:48 am
Contact:

[SOLVED] Migrations

Post 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?
Last edited by DRY411S on Fri Jun 17, 2016 8:16 pm, edited 1 time in total.
orzelek
Smart Inserter
Smart Inserter
Posts: 3928
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Migrations

Post 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.
User avatar
DRY411S
Filter Inserter
Filter Inserter
Posts: 736
Joined: Sun Mar 13, 2016 9:48 am
Contact:

Re: Migrations

Post 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:
orzelek
Smart Inserter
Smart Inserter
Posts: 3928
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: Migrations

Post 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.
User avatar
DRY411S
Filter Inserter
Filter Inserter
Posts: 736
Joined: Sun Mar 13, 2016 9:48 am
Contact:

Re: Migrations

Post 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. :)
Post Reply

Return to “Modding help”