Does "script.on_configuration_changed" only fire if my mod's version changes?
Or does it trigger if other mods or the game version changes also?
Thanks,
[Done] script.on_configuration_changed question
[Done] script.on_configuration_changed question
Last edited by TheSAguy on Mon Dec 17, 2018 5:46 pm, edited 1 time in total.
Re: script.on_configuration_changed question
TL;DR:Api doc wrote:This is called any time the game version changes, prototypes change, startup mod settings change, and any time mod versions change including adding or removing mods.
No
Yes
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Re: script.on_configuration_changed question
Okay, thanks Bilka,
I was wondering how I should handle the following.
I'm adding some global variables that I populate with the initial game settings. As an example:
So I only want to capture the Initial game setting, and not current running game, since the value might not be the same.
So I'm thought to only add this in the "script.on_init" phase. Knowing that that only runs on a new game (or first time you install the mod)
The problem with this is, if you update the mod from a previous version, the global setting will be missing.
So how do I only run my capturing script for a new game and ignore it if you update the mod in an existing game?
Thanks,
I was wondering how I should handle the following.
I'm adding some global variables that I populate with the initial game settings. As an example:
Code: Select all
global.settler_Group_min_size_NE = game.map_settings.enemy_expansion.settler_group_min_size
So I'm thought to only add this in the "script.on_init" phase. Knowing that that only runs on a new game (or first time you install the mod)
The problem with this is, if you update the mod from a previous version, the global setting will be missing.
So how do I only run my capturing script for a new game and ignore it if you update the mod in an existing game?
Thanks,
Re: script.on_configuration_changed question
The on config changed event gives you https://lua-api.factorio.com/latest/Con ... hangedData. You can use that to see if your mod existed:
Code: Select all
script.on_configuration_changed(function(event)
if (not event.mod_changes["your mod name"]) or event.mod_changes["your mod name"].old_version then
-- your mod was already installed
end
end)
event.mod_changes["your mod name"].old_version - old version exists, so your mod already existed in the save.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Re: script.on_configuration_changed question
Thanks Bilka, appreciate the help!