Property request: LuaTrain.signal
Posted: Sun Apr 21, 2019 8:08 am
A mod I am working on would benefit from having access to the rail signal a train is currently stopped at (if any).
This would be equivalent to the already existing LuaTrain.station.
Currently, getting this signal requires me to:
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.
Code: Select all
LuaTrain.signal :: LuaEntity [R] The rail signal this train is stopped at or nil.
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.