I have a per user mod setting. Changing it while the save is loaded works as it should using the on_runtime_mod_setting_changed event. However, I am unsure how to check the setting on save load. on_runtime_mod_setting_changed doesn't get called when a save is loaded. And now if the user is in the main menu, changes the mods setting and loads the game, this change isn't reflected in game.
The on_load bootstrap event won't work, since that's quite restricted.
How can I fetch my mods setting, and act accordingly on save loadup?
Fetching mod runtime settings on save load
Re: Fetching mod runtime settings on save load
That is all working correctly. By default the "Use mod settings per save" is enabled which means changing per-player settings from the main menu when a game is not loaded only has an effect on new save files. If the player disables that setting; loading a save will call 'on_runtime_mod_setting_changed', or if a player changes the setting while the save is loaded.
There's nothing you need to do different.
There's nothing you need to do different.
If you want to get ahold of me I'm almost always on Discord.
Re: Fetching mod runtime settings on save load
Ah, I see. Yeah, turning off per-save mod setting triggers the event. Thank you.
A different question: What would be the best way to run a function on save load, If I want to read/write to global?
A different question: What would be the best way to run a function on save load, If I want to read/write to global?
-
- Smart Inserter
- Posts: 2768
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: Fetching mod runtime settings on save load
You cannot write to global during load:
https://lua-api.factorio.com/latest/Lua ... ap.on_load
https://lua-api.factorio.com/latest/Lua ... ap.on_load
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
Re: Fetching mod runtime settings on save load
I know. I'm not looking to use on_load but rather a way to execute some code somewhere on the first few ticks after the save has been loaded.
Re: Fetching mod runtime settings on save load
That's not really allowed, though. Code executing inside the game should never change its behavior based on when a game was saved and loaded, or it will lead to desyncs (every client loads the save at a different time when they join, and even their player-specific GUi elements need to exist the same on every client). You get events when settings or mods change, and those sometimes happen coincidentally with save loads, but that's it.
My mods: Multiple Unit Train Control, Smart Artillery Wagons
Maintainer of Vehicle Wagon 2, Cargo Ships, Honk
Maintainer of Vehicle Wagon 2, Cargo Ships, Honk
-
- Smart Inserter
- Posts: 2768
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: Fetching mod runtime settings on save load
Yeah, unless someone else has a better idea, I’d suggest evaluating what it is that you’re actually trying to accomplish and why, and whether or not it’s actually needed (ie, do you really need to check the status of a mod setting on “load” instead of the change event?).
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
Re: Fetching mod runtime settings on save load
That's unfortunate. Thanks for the help! I'll try to find a different approach to my problem