Expose FluidBox::production_type

Post Reply
User avatar
Therax
Filter Inserter
Filter Inserter
Posts: 470
Joined: Sun May 21, 2017 6:28 pm
Contact:

Expose FluidBox::production_type

Post by Therax »

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.
Miniloader — UPS-friendly 1x1 loaders
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground

Bilka
Factorio Staff
Factorio Staff
Posts: 3130
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Expose FluidBox::production_type

Post by Bilka »

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.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Expose FluidBox::production_type

Post by Klonan »

Bilka 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.
If its in the prototype its enough, as the production type can't be changed at runtime anyway

But it could be nice to have a fluidbox.prototype as a shortcut

User avatar
Therax
Filter Inserter
Filter Inserter
Posts: 470
Joined: Sun May 21, 2017 6:28 pm
Contact:

Re: Expose FluidBox::production_type

Post by Therax »

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
Perfect. I missed that LuaFluidBoxPrototype was introduced in 0.17.
Miniloader — UPS-friendly 1x1 loaders
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground

User avatar
Therax
Filter Inserter
Filter Inserter
Posts: 470
Joined: Sun May 21, 2017 6:28 pm
Contact:

Re: Expose FluidBox::production_type

Post by Therax »

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.
Miniloader — UPS-friendly 1x1 loaders
Bulk Rail Loaders — Rapid train loading and unloading
Beltlayer & Pipelayer — Route items and fluids freely underground

Post Reply

Return to “Implemented mod requests”