Lua. Connect rail-signal to rail

Place to get help with not working mods / modding interface.
Post Reply
DedMorozzz
Burner Inserter
Burner Inserter
Posts: 5
Joined: Thu Oct 20, 2022 12:17 am
Contact:

Lua. Connect rail-signal to rail

Post by DedMorozzz »

Hi all, i'm trying to add rail-signals and rail-chain-signal to created rails, but i do not understand how to join them between each other..

Code: Select all

railEntity = surface.create_entity{ force=game.player.force, name = "straight-rail", position = fPos, direction = defines.direction.west}

sPos = shallowcopy(fPos)
sPos.x = sPos.x+1
sPos.y = sPos.y-2

railSignalEntity = surface.create_entity{ force=game.player.force, name = "rail-signal", position = sPos, direction = defines.direction.west}
sPos.y = sPos.y+3
surface.create_entity{ force=game.player.force, name = "rail-chain-signal", position = sPos, direction = defines.direction.east}
all works, i have a rail, and both signals, but signals are not connected to rail. How do join them?
Attachments
factorio-signals.jpg
factorio-signals.jpg (33.06 KiB) Viewed 483 times

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2250
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: Lua. Connect rail-signal to rail

Post by boskid »

Signals will automatically try to connect to rails when they are created. Only things you need to take care of is for the position to be exactly on a tile center, direction to be correct and to not have signals on an adjacent tile in the direction of a signal.

Your signals have incorrect direction.
Attachments
103806-connected-signals.png
103806-connected-signals.png (275.03 KiB) Viewed 472 times

DedMorozzz
Burner Inserter
Burner Inserter
Posts: 5
Joined: Thu Oct 20, 2022 12:17 am
Contact:

Re: Lua. Connect rail-signal to rail

Post by DedMorozzz »

boskid wrote:
Thu Oct 20, 2022 4:12 am
Your signals have incorrect direction.
Oh! You are right. Thank you, now it works

Post Reply

Return to “Modding help”