Page 1 of 1

script.on_init() contradicting documentation

Posted: Sun Aug 27, 2017 9:27 am
by Mathematics7
It's not clear to me when functions regisered by script.on_init() are called.
According to the factorio lua api: LuaBootstrap:
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.
But according to the factorio lua api: data-lifecycle:
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.
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?

Re: script.on_init() contradicting documentation

Posted: Sun Aug 27, 2017 10:43 am
by Optera
I don't see what the difference between new game and new save game should be.
Both mean when the world is initially created.

If anything new save game is phrased wrong as it can be misinterpreted as when you create a new save file.

Re: script.on_init() contradicting documentation

Posted: Sun Aug 27, 2017 5:54 pm
by Mathematics7
Oke, thank you. I misinterpreded 'new save game' as creating a saved game.