Automatic Train and Station Painter deprecated


Automagically colors locomotives, wagons, and stations based on the train's contents.

Content
5 years ago
0.17
10
Logistics

b [FIXED 0.3.2] Crash when painting an invalid station

5 years ago
(updated 5 years ago)

Not sure what cause it, but it think it happened right after a train leaves a refueling station.
That station managed by Train Supply Manager (TSM) Mod.
https://mods.factorio.com/mod/train-pubsub

Perhaps a conflict ?

Log :
134.642 Error MainLoop.cpp:1223: Exception at tick 58544066: The mod Automatic Train and Station Painter caused a non-recoverable error.
Please report this error to the mod author.

Error while running event automatic-train-and-station-painter::on_train_changed_state (ID 23)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
automatic-train-and-station-painter/painter.lua:109: in function 'paint_station'
automatic-train-and-station-painter/control.lua:50: in function <automatic-train-and-station-painter/control.lua:27>
stack traceback:
[C]: in function 'index'
__automatic-train-and-station-painter
/painter.lua:109: in function 'paint_station'
automatic-train-and-station-painter/control.lua:50: in function <automatic-train-and-station-painter/control.lua:27
186.739 Quitting: user-quit.

5 years ago

Thanks, it might be. I'm not familiar with TSM and how it manages stations, but it gives me a thread to pull on.

5 years ago

I was able to reproduce it by deleting the station after the train arrived. It had the same trace so it should fix it for TSM, too, though I didn't test against it.

5 years ago
(updated 5 years ago)

Ah, right. So, I'll channel Klonan: always check .valid on anything that has it (which is ~ every LUA API object) before using it. No matter what.

Which means that you need to check it both when our code is started by, eg, an event, or an input, or whatever, and also after any call to the API, since that can trigger events, and other mods can destroy things without raising an event. Checking .valid is effectively free, though, so you can safely do it too much and it won't even show up as a blip on the performance radar.

I strongly advise doing this preemptively if you don't want an unending string of these reports until you finally end up checking everywhere anyway, one bug at a time. :)

This thread has been locked.