[0.12.29][Oxyd] Crash when loading save - one mod active
Posted: Fri Apr 15, 2016 3:47 am
Hi, i'm testing my mod's ability to survive a save -> load transition, and currently it does not, but I don't know why. The logs do not help. What is the issue? It occurs when either one or both of my global simple tables (containing only Factorio classes in them in the form of entity references) contain something. For example with my mod, i can start a clean game, the tables are created but empty except for the Squad table which just has an empty UnitGroup in it, using the player name as a Key in the table.
When I place a droid soldier down, it (the on entity placed event callback function) adds that entity to the Solders global table, and then in an on-tick event adds every soldier in the list to the UnitGroup (in the global Squad table).
I then save the game, and then load the game, as a test. Every time I load a game which has a soldier unit crashes. I haven't tried killing the guy to see if his entity being nil or invalid helps at all.
I attached the mod exactly how it is currently, my save "ROBOTTEST", and the log file.
The important code is in the control.lua file btw, if there is a bug or i'm doing something wrong (or missed something critical like something I MUST do in the on_load event) please help me..
edit: I actually just managed to get it to save and load with a single soldier guy active, but then I spawned the remaining 4 that you start with and then tried the save->load cycle again, and this time it crashed again. Perhaps there is some unknown state that happens often, but I managed to get it in a "correct" state between attempts? maybe before the on_tick event custom code was called (only happens every 20 ticks so maybe I beat it to making the save)?
When I place a droid soldier down, it (the on entity placed event callback function) adds that entity to the Solders global table, and then in an on-tick event adds every soldier in the list to the UnitGroup (in the global Squad table).
I then save the game, and then load the game, as a test. Every time I load a game which has a soldier unit crashes. I haven't tried killing the guy to see if his entity being nil or invalid helps at all.
I attached the mod exactly how it is currently, my save "ROBOTTEST", and the log file.
The important code is in the control.lua file btw, if there is a bug or i'm doing something wrong (or missed something critical like something I MUST do in the on_load event) please help me..
edit: I actually just managed to get it to save and load with a single soldier guy active, but then I spawned the remaining 4 that you start with and then tried the save->load cycle again, and this time it crashed again. Perhaps there is some unknown state that happens often, but I managed to get it in a "correct" state between attempts? maybe before the on_tick event custom code was called (only happens every 20 ticks so maybe I beat it to making the save)?