Property request: LuaTrain.signal

Post Reply
eduran
Filter Inserter
Filter Inserter
Posts: 344
Joined: Fri May 09, 2014 2:52 pm
Contact:

Property request: LuaTrain.signal

Post 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.

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: Property request: LuaTrain.signal

Post by DaveMcW »


Bilka
Factorio Staff
Factorio Staff
Posts: 3132
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Property request: LuaTrain.signal

Post by Bilka »

Okay, added for the next version.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

eduran
Filter Inserter
Filter Inserter
Posts: 344
Joined: Fri May 09, 2014 2:52 pm
Contact:

Re: Property request: LuaTrain.signal

Post by eduran »

Thank you Bilka, much appreciated.

Post Reply

Return to “Implemented mod requests”