So far, I've got:
Code: Select all
local station = -- some LuaEntity of type 'train-stop'
local rail = station.connected_rail
-- repeating this next step zero or more times doesn't seem to help
rail = rail.get_connected_rail {
rail_direction = defines.rail_direction.back,
rail_connection_direction = defines.rail_connection_direction.straight
}
local signal = rail.get_rail_segment_entity(defines.rail_direction.back, true)