script.on_init() contradicting documentation
Posted: Sun Aug 27, 2017 9:27 am
It's not clear to me when functions regisered by script.on_init() are called.
According to the factorio lua api: LuaBootstrap:
According to the factorio lua api: LuaBootstrap:
But according to the factorio lua api: data-lifecycle:on_init(f)
Register a callback to be run on mod init. This is called once when a new save game is created or once when a save file is loaded that previously didn't contain the mod. This is always called before other event handlers and is meant for setting up initial values that a mod will use for its lifetime.
Parameters
- f :: function(): The function to call. Passing nil will unregister the handler.
The difference is one word (new game vs new save game), but it's quite a difference. Can anyone please tell me which one is correct?Using the mod order each mod is setup:
- When creating a new game, script.on_init() will be called on each mod that has a control.lua file.
When loading a save game and the mod existed in that save game script.on_load() is called.
When loading a save game and the mod did not exist in that save game script.on_init() is called.