I would like to introduce a cost multiplayer to some of my recipes. I would like to have the default for new installations set 5. But on the other hand: The one that equals the old recipes would be 10.
So I would like to set the value to 10 if the mod is updated from a older version to not break ratios.
Is there a nice way to do this via migrations? If I just set it in the migrations/foo.lua every subsequent update would set the value to 10.
So I am searching for something like a check witch version was the last one?
Settings defaults for older versions
-
davidsonmonster
- Manual Inserter

- Posts: 1
- Joined: Fri Jul 10, 2026 8:26 am
Re: Settings defaults for older versions
I don't think migrations expose the previous mod version directly. A common approach is to check whether your global setting or data already exists, and only initialize it if it's `nil`. That way new installs get the default value of 5, while existing saves can keep or migrate to 10 without overwriting it on every update.
Last edited by davidsonmonster on Wed Jul 29, 2026 10:58 am, edited 1 time in total.
Re: Settings defaults for older versions
If I understand it right a check for nil will always fail because the migrations stage is executed after the settings stage that sets the value to 5.
Re: Settings defaults for older versions
The default value of the setting is set during the settings stage and the recipe ratio is set during the data stage. Both are completed before the game loads to menu and cannot be changed automatically based on what save file is subsequently loaded.
The best you can do is a warning message that prints in on_configuration_changed telling that detects when the save was migrated from a 10x version but the seeing is 5x. It can tell the player to not save the game and go change the setting if they want it to stay the same.
The best you can do is a warning message that prints in on_configuration_changed telling that detects when the save was migrated from a 10x version but the seeing is 5x. It can tell the player to not save the game and go change the setting if they want it to stay the same.
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.

