on_configuration_changed on mod update
on_configuration_changed on mod update
I would like to run code when my mod gets updated, but on_configuration_changed only fires on factorio update or mod add/removal. May you also make it fire on mod update?
Re: on_configuration_changed on mod update
Are you sure?
http://lua-api.factorio.com/0.14.8/LuaB ... on_changed
[quote=api]This is called any time the game version changes and any time mod versions change including adding or removing mods.[/quote]
http://lua-api.factorio.com/0.14.8/LuaB ... on_changed
[quote=api]This is called any time the game version changes and any time mod versions change including adding or removing mods.[/quote]
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
I also update mods, some of them even work.
Recently I did a mod tutorial.
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: on_configuration_changed on mod update
Lots of mods use the event to update internal state (eg. stuff on `global`) when they have been updated. It definitely works. Something like this:
Code: Select all
script.on_configuration_changed( function(event)
local changed = event.mod_changes and event.mod_changes["your-mod-name"]
if changed then -- something to do with your mod
if not changed.old_version then
-- your mod was added
elseif not changed.new_version then
-- your mod was removed
else
-- your mod was updated
end
end
end )
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Re: on_configuration_changed on mod update
strange it doesn't trigger for me, but when i update factorio. Probably I did a misstake in my code than. Thx guys
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: on_configuration_changed on mod update
Did you get any errors when your script ran? Also, how were you testing that it was working? In that particular event it's usually best to use the global `log()` function to output stuff to game log (as game.players[id].print won't be available) in some cases.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.