
My mod listens for these events: on_init, on_load, on_tick, on_new_player.
New Game -> Everything is fine. on_init, on_load, on_tick, on_new_player are fired and the game variable exists and my mod's button that is created in the on_new_player event appears in the top bar just fine.
Load saved game previously without mod installed. on_init, on_load, on_tick are fired but on_new_player is not. This isn't a big deal and explains why all mods duplicate gui creation code between on_load and on_new_player. Easily fix in my mod.
Load save game previously with mod installed. on_init, on_load, on_tick are fired but on_new_player is not. Same reason as before. Now for the frustrating part. the "game" variable is suddenly nil for on_init and on_load but on_tick is fine.
Code: Select all
Unknown key:"Error while running the on_load: __CTest__/Ctest.lua:15: attempt to index global 'game' (a nil value)"