Spawn a north facing locomotive on an S-bend

Place to get help with not working mods / modding interface.
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3733
Joined: Tue May 13, 2014 11:06 am
Contact:

Spawn a north facing locomotive on an S-bend

Post 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 1416 times
quyxkh
Smart Inserter
Smart Inserter
Posts: 1031
Joined: Sun May 08, 2016 9:01 am
Contact:

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

Post 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..
User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3733
Joined: Tue May 13, 2014 11:06 am
Contact:

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

Post 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...
quyxkh
Smart Inserter
Smart Inserter
Posts: 1031
Joined: Sun May 08, 2016 9:01 am
Contact:

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

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

Return to “Modding help”