The behavior of target_pipe_connection_index, found in the PipeConnection structure returned by LuaFluidBox::get_pipe_connections(), is not immediately obvious when merged fluidbox prototypes are involved. I have determined experimentally that target_pipe_connection_index represents the index of the relevant connection within the concatenated list of all the pipe connections in all the fluidbox prototypes that were merged to make this prototype.
To make this very clear, I modded the chemical plant to have extra connections on each fluidbox prototype:
In this example, there are three merged fluidboxes: [1] = water, [2] = light oil, and [3] = petroleum gas.
entity.fluidbox.get_fluidbox_prototype(1) and (2) each return a single fluidbox prototype with two pipe connection definitions each.
entity.fluidbox.get_fluidbox_prototype(3) returns an array of two fluidbox prototypes, which each have two pipe connection definitions.
Looking at the yellow pipe, it is connected to the second pipe connection of the second fluidbox prototype merged into fluidbox 3. It is the fourth entry in the merged list of pipe connections from the two fluidbox prototypes that comprise fluidbox 3. Therefore, yellow_pipe.fluidbox.get_pipe_connections(1)[1] returns target_fluidbox_index = 3 and target_pipe_connection_index = 4.
I suggest adding a note to PipeConnection stating that target_pipe_connection_index indexes into a list formed by concatenating the pipe_connections list of each of the returned LuaFluidBoxPrototypes of a merged fluidbox. Or else add some simpler way to get access to the prototype PipeConnectionDefinition corresponding to each end of a particular active pipe connection.
In case you want to replicate my test, I have attached the test mod and save file. Hover your mouse cursor over any of the colored pipes and run the console command "/log_connections" to have it identify the corresponding pipe connection definition on the modified chemical plant in the log file.
Document behavior of target_pipe_connection_index
Document behavior of target_pipe_connection_index
- Attachments
-
- pipestufftest.zip
- (1.13 MiB) Downloaded 5 times
-
- WeirdPipeThings_0.0.1.zip
- (2.48 KiB) Downloaded 4 times
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
