Page 1 of 1

[Solved] Is migrating startup settings impossible?

Posted: Fri Aug 28, 2020 4:56 pm
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?

Re: Is migrating startup settings impossible?

Posted: Fri Aug 28, 2020 5:27 pm
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.

Re: Is migrating startup settings impossible?

Posted: Fri Aug 28, 2020 6:41 pm
by eradicator
I want to change the setting prototype name but keep the current values because the user might have changed them.

Re: Is migrating startup settings impossible?

Posted: Fri Aug 28, 2020 8:37 pm
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.

Re: Is migrating startup settings impossible?

Posted: Fri Aug 28, 2020 8:58 pm
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.

Re: Is migrating startup settings impossible?

Posted: Fri Aug 28, 2020 9:30 pm
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.

Re: Is migrating startup settings impossible?

Posted: Sat Aug 29, 2020 1:27 pm
by eradicator
Does nobody know the answer to the topic question?
Speculation isn't really what i'm interested in.

Re: Is migrating startup settings impossible?

Posted: Sat Aug 29, 2020 2:51 pm
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.

Re: Is migrating startup settings impossible?

Posted: Sat Aug 29, 2020 2:56 pm
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.

Re: Is migrating startup settings impossible?

Posted: Sat Aug 29, 2020 4:31 pm
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.

Re: Is migrating startup settings impossible?

Posted: Sat Aug 29, 2020 5:44 pm
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?