Page 1 of 1

Spawn a north facing locomotive on an S-bend

Posted: Tue Feb 27, 2018 11:50 pm
by DaveMcW
I have an S-bend with 1 straight rail and a station in the middle. How can I spawn a north facing locomotive at the station?

I tried

Code: Select all

/c game.player.surface.create_entity{name="locomotive", direction=defines.direction.north, position=straight_rail.position, force=game.player.force}
but the train faces south.
s-bend.jpg
s-bend.jpg (590.55 KiB) Viewed 1464 times

Re: Spawn a north facing locomotive on an S-bend

Posted: Wed Feb 28, 2018 3:48 am
by quyxkh
Seems directions are reversed on curved rail, plus I can get the train-stop's rail from its position and direction but "front" and "back" from there seem pretty arbitrary..

Re: Spawn a north facing locomotive on an S-bend

Posted: Wed Feb 28, 2018 4:33 am
by DaveMcW
quyxkh wrote:Seems directions are reversed on curved rail
Thanks, reversing direction worked!

Code: Select all

/c game.player.surface.create_entity{name="locomotive", direction=defines.direction.south, position=straight_rail.position, force=game.player.force}
I have no idea why it works...

Re: Spawn a north facing locomotive on an S-bend

Posted: Fri Mar 02, 2018 11:35 pm
by quyxkh
I think it's trying to snap the pointy end of create_entity'd locomotives to a nearby train stop, as is done when hand-placing locomotives, but it only works as intended when the snap puts the locomotive on straight rail. When you're hand-placing a locomotive on curved rail it doesn't do the snapping at all, but c-e still tries sometimes, and flips the direction.