Generic train carriage direction in train

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
shanemadden
Fast Inserter
Fast Inserter
Posts: 128
Joined: Thu Feb 08, 2018 8:25 am
Contact:

Generic train carriage direction in train

Post 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.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15545
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Generic train carriage direction in train

Post by Rseding91 »

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.
shanemadden
Fast Inserter
Fast Inserter
Posts: 128
Joined: Thu Feb 08, 2018 8:25 am
Contact:

Re: Generic train carriage direction in train

Post 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?
Post Reply

Return to “Modding interface requests”