[Solved] Is migrating startup settings impossible?

Place to get help with not working mods / modding interface.
Post Reply
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

[Solved] Is migrating startup settings impossible?

Post by eradicator »

During cleanup of an old mod i'm changing the names of most things to include proper prefixes. Migrating entites/recipes etc works, but the migrations for startup settings in the exact same .json file have no effect.

The documentations states that:
The API Documentation wrote: JSON migrations are applied as a map is loaded.
At which point startup settings can not be affected anymore.

So can anybody confirm or deny that this is indeed impossible?
Last edited by eradicator on Sat Aug 29, 2020 5:50 pm, edited 1 time in total.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

robot256
Filter Inserter
Filter Inserter
Posts: 596
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: Is migrating startup settings impossible?

Post by robot256 »

What are you changing that has to be migrated? When I use startup settings, they are only referenced in my own code so making the new version of my mod self-consistent is enough.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Is migrating startup settings impossible?

Post by eradicator »

I want to change the setting prototype name but keep the current values because the user might have changed them.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

robot256
Filter Inserter
Filter Inserter
Posts: 596
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: Is migrating startup settings impossible?

Post by robot256 »

eradicator wrote:
Fri Aug 28, 2020 6:41 pm
I want to change the setting prototype name but keep the current values because the user might have changed them.
Ah. That's a tough one, and it's a complicated matter for the game engine because the migration would also have to be applied when deciding whether to synchronize startup settings before loading a save or joining a game. Unless you are refactoring what the settings do at the same time, I would be strongly inclined to keep the old terrible names and simply change the locale strings.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Is migrating startup settings impossible?

Post by eradicator »

robot256 wrote:
Fri Aug 28, 2020 8:37 pm
Ah. That's a tough one, and it's a complicated matter for the game engine because the migration would also have to be applied when deciding whether to synchronize startup settings before loading a save or joining a game.
I can't follow that logic. Startup settings are evaluate exactly once at the end of the settings phase during startup. So the migration would only have to be done once too.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

robot256
Filter Inserter
Filter Inserter
Posts: 596
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: Is migrating startup settings impossible?

Post by robot256 »

eradicator wrote:
Fri Aug 28, 2020 8:58 pm
robot256 wrote:
Fri Aug 28, 2020 8:37 pm
Ah. That's a tough one, and it's a complicated matter for the game engine because the migration would also have to be applied when deciding whether to synchronize startup settings before loading a save or joining a game.
I can't follow that logic. Startup settings are evaluate exactly once at the end of the settings phase during startup. So the migration would only have to be done once too.
I take back the part about joining multiplayer games: the server will already have the new version of the mod and the new setting names.

Startup settings are stored in more than one place: in the factorio.ini (?) with your selections from the main menu, and in every savegame file with the selections at the time it was saved. Since Factorio never alters a savegame file unless you hit "save" in game, the old saves will still have the old-style startup setting names after you start the game with the new mod version. So the migration will have to be applied again if the user selects "sync mods with save -> sync startup settings with save". (If that option is not checked, the settings from the main menu will override those of the save file.)

Edit: Also to say this is not an unreasonable request, but certainly would have to be in the game engine. It would also have handle, or explicitly deny, simultaneous changes in setting type or options. You would need JSON migrations for each entry in a drop-down menu, for example.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Is migrating startup settings impossible?

Post by eradicator »

Does nobody know the answer to the topic question?
Speculation isn't really what i'm interested in.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

robot256
Filter Inserter
Filter Inserter
Posts: 596
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: Is migrating startup settings impossible?

Post by robot256 »

We've both thoroughly tested all the known API methods and proven it's impossible (I tried JSON and LUA just now). You're asking if there is a magic undocumented back-channel that does something the documentation implies should be covered by JSON. Factorio is joyfully devoid of entirely undocumented API features like that. This is clearly a bug in the game or documentation or both, so you should ask the Devs to correct them in a bug report or interface request. They are pretty good about correcting documentation errors.

Bilka
Factorio Staff
Factorio Staff
Posts: 3128
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Is migrating startup settings impossible?

Post by Bilka »

eradicator wrote:
Fri Aug 28, 2020 4:56 pm
During cleanup of an old mod i'm changing the names of most things to include proper prefixes. Migrating entites/recipes etc works, but the migrations for startup settings in the exact same .json file have no effect.

The documentations states that:
The API Documentation wrote: JSON migrations are applied as a map is loaded.
At which point startup settings can not be affected anymore.

So can anybody confirm or deny that this is indeed impossible?
Json migrations indeed do not work for startup mod settings.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

robot256
Filter Inserter
Filter Inserter
Posts: 596
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: Is migrating startup settings impossible?

Post by robot256 »

Bilka wrote:
Sat Aug 29, 2020 2:56 pm
Json migrations indeed do not work for mod settings.
But it does actually work for runtime-global settings. It shows up in the migration results dialog after loading a game and preserves the value in the save file.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Is migrating startup settings impossible?

Post by eradicator »

Bilka wrote:
Sat Aug 29, 2020 2:56 pm
Json migrations indeed do not work for startup mod settings.
Thank you, that's what i feared. I'm guessing it's also not realistic to put an interface request for that?
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Modding help”