Page 1 of 1

Generic train carriage direction in train

Posted: Wed Jun 27, 2018 3:20 pm
by shanemadden
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.

Re: Generic train carriage direction in train

Posted: Fri Jun 29, 2018 11:40 am
by Rseding91
0.17 has an entity.clone() option which will preserve everything about the entity and put a copy somewhere else.

Re: Generic train carriage direction in train

Posted: Fri Jun 29, 2018 2:39 pm
by shanemadden
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?