As mentioned in this thread there is currently no way to determine if a train is facing forward or backwards.
Neither front_stock/back_stock nor front_movers/back_movers actually reflect which part of the train is facing forward.
When driving there's the hack of getting negative speeds while in reverse, but that's no option for determining which way a train parked at a stop is facing.
API doesn't provide a way to get front/back of trains in stations
API doesn't provide a way to get front/back of trains in stations
Last edited by Optera on Tue Mar 28, 2017 6:25 pm, edited 1 time in total.
My Mods: mods.factorio.com
-
- Inserter
- Posts: 47
- Joined: Fri Mar 17, 2017 9:19 pm
- Contact:
Re: API doesn't provide a way to get front/back trains
it might help to why this information is needed? what does this information allow a mod to do that it cannot do now?
Re: API doesn't provide a way to get front/back trains
Did you consider rotation of locomotive?Optera wrote:As mentioned in this thread there is currently no way to determine if a train is facing forward or backwards.
Neither front_stock/back_stock nor front_movers/back_movers actually reflect which part of the train is facing forward.
When driving there's the hack of getting negative speeds while in reverse, but that's no option for determining which way a train parked at a stop is facing.
Re: API doesn't provide a way to get front/back trains
For example in LTN I provide train composition signals.SilverB1rd wrote:it might help to why this information is needed? what does this information allow a mod to do that it cannot do now?
I'm sure we agree an LL-C-L with the 2 locos facing the stop needs different inserters active when refueling than when the single loco faces the stop.
So I was getting the LuaTrain.carriages but with no indicator which way is front I have no clue which direction i should parse it to provide an accurate representation according to the way the train faces inside the station.
There are ppl out there using multi headed 2 way trains. Loco orientation does nothing.orzelek wrote:Did you consider rotation of locomotive?
Edit:
In simple terms, if LuaTrain.station is set there should be an indication which way is facing that station.
It can be as simple as a boolean LuaTrain.front_facing_station. true when front_stock is facing it and false when back_stock is facing it.
My Mods: mods.factorio.com
-
- Inserter
- Posts: 47
- Joined: Fri Mar 17, 2017 9:19 pm
- Contact:
Re: API doesn't provide a way to get front/back of trains in stations
Maybe..
If LuaTrain.Station is set, Calculate the distance between the front_movers{1}.position, back_movers{1}.position, and the station.position, the one with the shortest distance is the one at the station.
If LuaTrain.Station is set, Calculate the distance between the front_movers{1}.position, back_movers{1}.position, and the station.position, the one with the shortest distance is the one at the station.
Re: API doesn't provide a way to get front/back of trains in stations
Trains have no concept of "forward" and "backwards" except in relation to the locomotive the player is sitting in.
What do you mean by "front"? If you have 2 locomotives each facing the opposite direction connected to each other which is "front"? If you're driving to the north in the south locomotive then again what is "front"? The one you're in or the one facing north? And if you get in the other then what is "front" again?
If you can better define what you're trying to do maybe I could make suggestions or expand the API to address your particular problem.
What do you mean by "front"? If you have 2 locomotives each facing the opposite direction connected to each other which is "front"? If you're driving to the north in the south locomotive then again what is "front"? The one you're in or the one facing north? And if you get in the other then what is "front" again?
If you can better define what you're trying to do maybe I could make suggestions or expand the API to address your particular problem.
If you want to get ahold of me I'm almost always on Discord.
Re: API doesn't provide a way to get front/back of trains in stations
The best definition of front for stationary trains with LuaTrain.station set would be front = closest to station back = furthest from station.Rseding91 wrote:Trains have no concept of "forward" and "backwards" except in relation to the locomotive the player is sitting in.
What do you mean by "front"? If you have 2 locomotives each facing the opposite direction connected to each other which is "front"? If you're driving to the north in the south locomotive then again what is "front"? The one you're in or the one facing north? And if you get in the other then what is "front" again?
If you can better define what you're trying to do maybe I could make suggestions or expand the API to address your particular problem.
When station is nil the indicator for front can be nil too, as manual trains have no front.
As stated above I want to provide train composition from LuaTrain.carriages. What I lack is any indicator if carriages[1] or carriages[#carriages] is closest to the station.
I hope that makes sense now.
My Mods: mods.factorio.com