Train Controller

by Vendan

Control train schedules via circuit conditions

Content
7 years ago
0.15
6
Trains

b Error after leaving a GUI open and removing the structure it originates from

7 years ago

I encountered a bug when I had a combinator GUI open and mined the combinator without closing the GUI. (Persumably) this mod started to produce an error every second after that, not even reloading worked - I had to go back to an autosave before I mined the combinator.

I tried this with a few other entities and it worked (or, should I say, crashed) consistently - place a chest, open its inventory, while it's open, mine the chest (same for almost all, if not all GUI entities).

The error message was:
"LuaEntityAPI call when LuaEntity was invalid. stack traceback: train-controller/control.lua:126: in function 'gui_close' train-controller/control.lua:179: in function <train-controller/control.lua:171> [C]: in function 'pcall' train-controller/control.lua:171: in function <train-controller/control.lua:159>

7 years ago
(updated 7 years ago)

I messed with the mod control file and I have no idea if this is optimal, but it did work in the end. I added a few fallback lines into the gui_close() function that check whether the closed inventory entity is still valid, and if it isn't, it returns from the function.

function gui_close(player, controller)
if not pcall(function()
if controller.name then end
end) then
return
end
...

It might still be suboptimal, as I have never tried making mods for Factorio, so I don't know the API well, but it worked.

I hope this helps!

New response