Page 1 of 1

[0.17.39][API request] Access stopped train (or nil) from train stop entity

Posted: Wed May 15, 2019 4:38 pm
by lovely_santa
Hi,

Imagine I have a train stop entity and I want to know if a train is stopped at the station, and if so, I want the LuaTrain.
As of now, starting from the entity I have to do this: As bilka mensioned on discord (as he should first look then answer this - his request), the train stop has a function that basicaly goes -> find connected rail -> find train. This could have a nice performance boost to not have to search the surface to get the train that is stopped at a specific station by just TrainStopEntity.stopped_train returning a LuaTrain or nil when no train is stopped.

Kind regards
lovely_santa

Re: [0.17.39][API request] Access stopped train (or nil) from train stop entity

Posted: Wed May 15, 2019 7:22 pm
by eradicator
+1

Though I'd want the station only to give back the train if it is stopped at *that* station, not if it just happens to be "parked" near the station. I.e. "TrainStop.stopped_train" should be nil, whenever the "read stopped train" circuit network signal would be nil.

In the picture i'd expect the left double-station to not report a train.
trainstop.png
trainstop.png (640.61 KiB) Viewed 1097 times

Re: [0.17.39][API request] Access stopped train (or nil) from train stop entity

Posted: Wed May 15, 2019 7:50 pm
by lovely_santa
eradicator wrote: Wed May 15, 2019 7:22 pm +1

Though I'd want the station only to give back the train if it is stopped at *that* station, not if it just happens to be "parked" near the station. I.e. "TrainStop.stopped_train" should be nil, whenever the "read stopped train" circuit network signal would be nil.
Yes! I forgot to mension that. I've updated the initial post as well

Re: [0.17.39][API request] Access stopped train (or nil) from train stop entity

Posted: Fri May 17, 2019 9:08 am
by Bilka
Okay, added in the next version. It will only work for trains that are currently stopped at that train station, not just "standing there", as requested.