on_startup_mod_settings_changed
Posted: Tue May 23, 2017 8:01 am
I've noticed that since I heavily make use of "startup" options to edit the data table from the mod options, Recipes and Technologies are NOT changed to match what you change the settings to when loading a savegame.
one possible solution is to force a reset_recipes() and reset_technologies() event, as well as actually trigger a "on_startup_mod_settings_changed" event to run the equivalent of a migration script. (though if you trigger an event, reset_recipes() and reset_technologies() don't need to be forced as they can be included in the event.)
EG, if a mod update adds a new entity to the game, and adds that unlock to an existing technology, then you'd have a migration script run like this:
What I feel we need is the ability to add something like that in control.lua to be triggered when startup settings have changed.
Basically, what I'm asking for is this event, but for startup settings http://lua-api.factorio.com/latest/even ... ng_changed
EG:
one possible solution is to force a reset_recipes() and reset_technologies() event, as well as actually trigger a "on_startup_mod_settings_changed" event to run the equivalent of a migration script. (though if you trigger an event, reset_recipes() and reset_technologies() don't need to be forced as they can be included in the event.)
EG, if a mod update adds a new entity to the game, and adds that unlock to an existing technology, then you'd have a migration script run like this:
Code: Select all
for index, force in pairs(game.forces) do
force.reset_recipes()
force.reset_technologies()
if force.recipes["bob-distillery"] and force.technologies["electrolysis-1"].researched then
force.recipes["bob-distillery"].enabled = true
end
end
Basically, what I'm asking for is this event, but for startup settings http://lua-api.factorio.com/latest/even ... ng_changed
EG:
Code: Select all
script.on_runtime_mod_setting_changed(function(event)
if event.setting == "bobmods-plates-purewater" and settings.startup["bobmods-plates-purewater"].value == true then
for index, force in pairs(game.forces) do
force.reset_recipes()
force.reset_technologies()
if force.recipes["bob-distillery"] and force.technologies["electrolysis-1"].researched then
force.recipes["bob-distillery"].enabled = true
end
end
end
end)