Additional railway queries API
Posted: Sun Jun 26, 2022 4:20 pm
1. Make `get_connected_rail` also return the connection direction of the returned rail. So for example with the following setup
Use-case: https://github.com/Sopel97/railway_sign ... #L721-L743
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)
Use-case: https://github.com/Sopel97/railway_sign ... #L648-L674
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:
6. A single function that returns a luatable with all signals in a segment (potentially optionally include signals on the boundary of the segment? they are currently not returned by `get_rail_segment_entity`. Equivalent to something like this:
7. Potentially a function that returns all start rails of blocks that a chain signal waits for to clear up?
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