Page 1 of 1

Property request: LuaTrain.signal

Posted: Sun Apr 21, 2019 8:08 am
by eduran
A mod I am working on would benefit from having access to the rail signal a train is currently stopped at (if any).

Code: Select all

LuaTrain.signal :: LuaEntity [R]	The rail signal this train is stopped at or nil.
This would be equivalent to the already existing LuaTrain.station.

Currently, getting this signal requires me to:
  • figure out, which direction the train wants to go in (this is hard with a stopped train)
  • get one of the rails the train is parked on (e.g. LuaTrain.front_rail)
  • get the correct signal at the end of the segment (LuaEntity.get_rail_segment_entity(correct_direction, false))

My use case:
Train ALert GUI displays train related alerts, e.g. trains waiting longer than a certain amount of time at a station or signal. This is useful to detect train jams or slow stations. However, some stations (stackers, depots) or signals (in front of stackers /depots) should be exempt from the general timeout. I can create an ignore list for those stops and signals, but still need to figure out if a train is stopped at one of those. LuaTrain.station already allows me to do one half of that and LuaTrain.signal would cover the same case for signals.

Re: Property request: LuaTrain.signal

Posted: Sun Apr 21, 2019 7:41 pm
by DaveMcW

Re: Property request: LuaTrain.signal

Posted: Wed Apr 24, 2019 2:09 pm
by Bilka
Okay, added for the next version.

Re: Property request: LuaTrain.signal

Posted: Wed Apr 24, 2019 4:04 pm
by eduran
Thank you Bilka, much appreciated.