LuaFluidBox::get_connections(index) returns an array, with one entry per connected pipe connection, but if less than all of them are connected it's impossible to determine which entry maps to which pipe connection.
The most important vanilla entity in this respect is the pump, because the two pipe connections are not interchangeable: one is input and one is output. If only one is connected, get_connections(1) returns an array of one element, without distinguishing which pipe connection is connected.
Proposals:
- Instead of having get_connections(index) return an array, have it return an associative map. Under this proposal, a pump with only its input connected (pipe connection 2 in the protoype) would return:
Type (input/output) could then be determined by referencing LuaFluidBoxPrototype::pipe_connections.
Code: Select all
{ [1] = nil, [2] = connected_entity_fluidbox }
- Instead of having get_connections(index) return an array of FluidBoxes, have it return an array of records. This would be similar to how CircuitConnectionDefinition's source_circuit_id works for decider and arithmetic combinators. Under this proposal, a pump with only its input connected would return something like:
Code: Select all
{ { source_pipe_connection_id = 2, source_pipe_connection_type = "input", target_fluidbox = connected_entity_fluidbox, target_fluidbox_index = 1, target_pipe_connection_id = 1, target_pipe_connection_type = "input-output", } }