It would nice to be able to determine whether a given pipe connection and/or fluid box was for input or output, whether exposed via LuaEntityPrototype or LuaFluidBox.
I'm making a mod that does bulk long-distance transfer of liquids, and it would be nice to be able to automatically determine which connections are sources and which are sinks. While I can hard-code the mapping for vanilla entities, for modded entities it's impossible to predict. The goal of the mod is mitigating the UPS cost of large nuclear power setups, but could be used with any fluid.
Expose FluidBox::production_type
Expose FluidBox::production_type
Miniloader — UPS-friendly 1x1 loaders
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground
Re: Expose FluidBox::production_type
Do you want this for LuaEntity or LuaEntityPrototype? If you want it for the prototype, it's already exposed in 0.17 via LuaEntityPrototype::fluidbox_prototypes and https://lua-api.factorio.com/0.17.0-pre ... otype.html
If you want it from LuaEntity/LuaFluidBox I'll look into getting the fluid box prototype from the LuaFluidBox.
If you want it from LuaEntity/LuaFluidBox I'll look into getting the fluid box prototype from the LuaFluidBox.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Re: Expose FluidBox::production_type
If its in the prototype its enough, as the production type can't be changed at runtime anywayBilka wrote:Do you want this for LuaEntity or LuaEntityPrototype? If you want it for the prototype, it's already exposed in 0.17 via LuaEntityPrototype::fluidbox_prototypes and https://lua-api.factorio.com/0.17.0-pre ... otype.html
If you want it from LuaEntity/LuaFluidBox I'll look into getting the fluid box prototype from the LuaFluidBox.
But it could be nice to have a fluidbox.prototype as a shortcut
Re: Expose FluidBox::production_type
Perfect. I missed that LuaFluidBoxPrototype was introduced in 0.17.Bilka wrote:If you want it for the prototype, it's already exposed in 0.17 via LuaEntityPrototype::fluidbox_prototypes and https://lua-api.factorio.com/0.17.0-pre ... otype.html
Miniloader — UPS-friendly 1x1 loaders
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground
Re: Expose FluidBox::production_type
This is actually related: is there or can there be a way to determine which pipe_connection of a fluidbox is connected? Here's the scenario:
I have a pump. I know from examining the LuaFluidBoxPrototype and FluidBoxConnection (and why isn't that named FluidBoxConnectionPrototype?) that the pump has 1 fluidbox and 2 connections on that fluidbox, with the 1st being output and the 2nd being input.
I start with a reference to a pipe connected to the pump. I can call pipe.fluidbox.get_connections(1) to get a reference to the pump's LuaFluidBox, and pump_fluidbox.owner to get a reference to the pump entity. I don't know whether my pipe is connected to the pump's input or output, and I need to learn this information.
If nothing else is connected to the pump, I can call pump_fluidbox.get_connections(1) and get an array of LuaFluidBox references, containing only one entry, which is my pipe's LuaFluidBox. I can't see any way to determine from here whether this is an input or output connection.
If something else is connected to the pump, calling pump_fluidbox.get_connections(1) returns an array of 2 LuaFluidBox references, one of which is my pipe's LuaFluidBox. However, the order of the array returned from pump_fluidbox.get_connections(1) is unpredictable. Sometimes the input connection appears first, sometimes the output connection appears first, and it appears to be determined by entity construction order.
I have a pump. I know from examining the LuaFluidBoxPrototype and FluidBoxConnection (and why isn't that named FluidBoxConnectionPrototype?) that the pump has 1 fluidbox and 2 connections on that fluidbox, with the 1st being output and the 2nd being input.
I start with a reference to a pipe connected to the pump. I can call pipe.fluidbox.get_connections(1) to get a reference to the pump's LuaFluidBox, and pump_fluidbox.owner to get a reference to the pump entity. I don't know whether my pipe is connected to the pump's input or output, and I need to learn this information.
If nothing else is connected to the pump, I can call pump_fluidbox.get_connections(1) and get an array of LuaFluidBox references, containing only one entry, which is my pipe's LuaFluidBox. I can't see any way to determine from here whether this is an input or output connection.
If something else is connected to the pump, calling pump_fluidbox.get_connections(1) returns an array of 2 LuaFluidBox references, one of which is my pipe's LuaFluidBox. However, the order of the array returned from pump_fluidbox.get_connections(1) is unpredictable. Sometimes the input connection appears first, sometimes the output connection appears first, and it appears to be determined by entity construction order.
Miniloader — UPS-friendly 1x1 loaders
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground