Rail signals have two placement positions on a straight rail.
If the rail signal is at the further away position from the source rail for get_rail_segment_entity, the rail signal entity is returned.
However if the rail signal is at the closer position, get_rail_segment_entity returns nil.
I expect it to return the signal in both cases.
[0.18.19] get_rail_segment_entity returns nil for rail signals at nearer position on rail
-
- Inserter
- Posts: 47
- Joined: Mon Aug 27, 2018 12:46 pm
- Contact:
Re: [0.18.19] get_rail_segment_entity returns nil for rail signals at nearer position on rail
Code: Select all
/c
local rail = game.player.selected
game.print("front in: "..rail.get_rail_segment_entity(defines.rail_direction.front, true).unit_number)
game.print("front out: "..rail.get_rail_segment_entity(defines.rail_direction.front, false).unit_number)
game.print("back in: "..rail.get_rail_segment_entity(defines.rail_direction.back, true).unit_number)
game.print("back out: "..rail.get_rail_segment_entity(defines.rail_direction.back, false).unit_number)
I suspect you may be confused about where the rail segment end is. In above case, there are 2 rail segments, left one will have 2 signals and right (with single rail piece) will have another 2 signals
-
- Inserter
- Posts: 47
- Joined: Mon Aug 27, 2018 12:46 pm
- Contact:
Re: [0.18.19] get_rail_segment_entity returns nil for rail signals at nearer position on rail
Segment - a series of rails that are not split in between by junctions, signals or stations. The basic unit for pathfinder.
Above returns nil in all cases
Above works fine
Re: [0.18.19] get_rail_segment_entity returns nil for rail signals at nearer position on rail
Due to the signals, you have 3 rail segments on both images. In first case left segment will have 2 signals, center segment will have 0 signals and right segment will have 2 signals. In second case left segment will have 0 signals, center segment will have 4 signals and right segment will have 0 signals. This is working as expected and is not going to change.