Code: Select all
F - front, B - back, [a-z] - identifiers, -> - connection
rail(F a B) -> rail(B b F)
a.get_connected_rail(defines.rail_direction.back, ...) -> (b, defines.rail_direction.back)
2. A function to get a traffic direction on a rail as defined by connected signals (from the point of view of a rail passed as a parameter). This could also cover more cases than just inferring from segment's signals (which is what is possible now in script, see use-case below)
Code: Select all
local rail_traffic_direction = {
indeterminate = 0,
forward = 1,
backward = 2,
universal = 3
}
3. A function to get all rail entities in a segment (defined by some rail inside it). It's doable from script but it's painful. See https://github.com/Sopel97/railway_sign ... #L760-L810
4. A way to access railway block information (in extended entity info view in game it already shows this). For example for checking if two segments are part of the same block or not - for this I'm currently doing the following, but it's not perfect and doesn't catch all cases https://github.com/Sopel97/railway_sign ... #L812-L843.
.
4.1. Potentially information about all railway block endpoints, with end signal entities and end rail entities along with their connection direction information.
5. A single function that returns a luatable with all neighbours. Equivalent to something like this:
Code: Select all
local function get_rail_neighbours(rail, dir)
local entities = {}
insert_if_not_nil(entities, rail.get_connected_rail{rail_direction=dir, rail_connection_direction=defines.rail_connection_direction.left})
insert_if_not_nil(entities, rail.get_connected_rail{rail_direction=dir, rail_connection_direction=defines.rail_connection_direction.straight})
insert_if_not_nil(entities, rail.get_connected_rail{rail_direction=dir, rail_connection_direction=defines.rail_connection_direction.right})
return back_entities, entities
end
Code: Select all
local function get_segment_signals_and_traffic_direction(rail)
return {
front_in = rail.get_rail_segment_entity(defines.rail_direction.front, true),
front_out = rail.get_rail_segment_entity(defines.rail_direction.front, false),
back_in = rail.get_rail_segment_entity(defines.rail_direction.back, true),
back_out = rail.get_rail_segment_entity(defines.rail_direction.back, false)
}
end