When looking at all the carriages on a LuaTrain, you can tell which of the locomotive carriages are facing backward or forward by checking which .locomotives array they're present in, but for the remaining carriages the best way I can find to determine their current facing is to compare .orientation (which gets complex fast if the train's on a curve).
For my purposes it's pretty much cosmetic (faithfully keeping which way the artillery cars are facing) but it'd be nice to have a way to easily see which carriages are forward-facing and which are back-facing for the whole train.
Generic train carriage direction in train
-
- Fast Inserter
- Posts: 128
- Joined: Thu Feb 08, 2018 8:25 am
- Contact:
Re: Generic train carriage direction in train
0.17 has an entity.clone() option which will preserve everything about the entity and put a copy somewhere else.
If you want to get ahold of me I'm almost always on Discord.
-
- Fast Inserter
- Posts: 128
- Joined: Thu Feb 08, 2018 8:25 am
- Contact:
Re: Generic train carriage direction in train
That's going to be a really useful improvement over how I'm doing some of the "make new copy from template train" process now, but I'm not sure if it's going to help for this specific case of keeping the new train car facing the same way relative to the rest of the train (as the template might be on a different orientation of track) - would the normal carriage placement snapping-to-rail-and-other-trains logic happen with the clone, or is there any special behavior there to ensure the carriage's stock connection state and relative orientation are maintained?