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

User avatar
lovely_santa
Filter Inserter
Filter Inserter
Posts: 502
Joined: Sat Feb 18, 2017 9:41 pm
Contact:

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

Post 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
Last edited by lovely_santa on Wed May 15, 2019 8:10 pm, edited 6 times in total.
You can find all my mods on the mod portal. Also helping on Arch666Angel's mods.
Image
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post 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 1094 times
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
User avatar
lovely_santa
Filter Inserter
Filter Inserter
Posts: 502
Joined: Sat Feb 18, 2017 9:41 pm
Contact:

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

Post 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
You can find all my mods on the mod portal. Also helping on Arch666Angel's mods.
Image
Bilka
Factorio Staff
Factorio Staff
Posts: 3314
Joined: Sat Aug 13, 2016 9:20 am
Contact:

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

Post 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.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Post Reply

Return to “Implemented mod requests”