LuaFluidBox

class LuaFluidBox - sort
get_prototype(index) → LuaFluidBoxPrototype The prototype of this fluidbox index.
get_capacity(index) → double The capacity of the given fluidbox index.
get_connections(index) → array of LuaFluidBox The fluidbox connections for the given fluidbox index.
get_filter(index) → table The filter of the given fluidbox index, 'nil' if none.
set_filter(index, table) → boolean Set the filter of the given fluidbox index, 'nil' to clear.
get_flow(index) → double Flow through the fluidbox in the last tick.
get_locked_fluid(index) → string Returns the fluid the fluidbox is locked onto (along with its whole system) Returns 'nil' for no lock
operator # :: uint [R] Number of fluid boxes.
owner :: LuaEntity [R] The entity that owns this fluidbox.
operator [] :: Fluid or nil [R] Access, set or clear a fluid box.
valid :: boolean [R] Is this object valid?
help() → string All methods, and properties that this object supports.

An array of fluid boxes of an entity. Entities may contain more than one fluid box, and some can change the number of fluid boxes -- for instance, an assembling machine will change its number of fluid boxes depending on its active recipe.

See Fluid

Do note that reading from a LuaFluidBox creates a new table and writing will copy the given fields from the table into the engine's own fluid box structure. Therefore, the correct way to update a fluidbox of an entity is to read it first, modify the table, then write the modified table back. Directly accessing the returned table's attributes won't have the desired effect.

Example
Double the temperature of the fluid in entity's first fluid box.
fluid = entity.fluidbox[1]
fluid.temperature = fluid.temperature * 2
entity.fluidbox[1] = fluid
get_prototype(index) → LuaFluidBoxPrototype

The prototype of this fluidbox index.

Parameters
index :: uint
get_capacity(index) → double

The capacity of the given fluidbox index.

Parameters
index :: uint
get_connections(index) → array of LuaFluidBox

The fluidbox connections for the given fluidbox index.

Parameters
index :: uint
get_filter(index) → table

The filter of the given fluidbox index, 'nil' if none.

Parameters
index :: uint
Return value
  • name :: string: Fluid prototype name of the filtered fluid.
  • minimum_temperature :: double: The minimum temperature allowed into the fluidbox
  • maximum_temperature :: double: The maximum temperature allowed into the fluidbox
or 'nil'.
set_filter(index, table) → boolean

Set the filter of the given fluidbox index, 'nil' to clear. Some entities cannot have their fluidbox filter set, notably fluid wagons and crafting machines.

Parameters
index :: uint
table: Table with the following fields:
  • name :: string: Fluid prototype name of the filtered fluid.
  • minimum_temperature :: double (optional): The minimum temperature allowed into the fluidbox
  • maximum_temperature :: double (optional): The maximum temperature allowed into the fluidbox
  • force :: boolean (optional): Force the filter to be set, regardless of current fluid content.
or 'nil'.
Return value
If the filter was set successfully.
get_flow(index) → double

Flow through the fluidbox in the last tick. It is the larger of in-flow and out-flow. Note that wagons do not track it and will return 0.

Parameters
index :: uint
get_locked_fluid(index) → string

Returns the fluid the fluidbox is locked onto (along with its whole system) Returns 'nil' for no lock

Parameters
index :: uint
operator # :: uint [Read-only]

Number of fluid boxes.

owner :: LuaEntity [Read-only]

The entity that owns this fluidbox.

operator [] :: Fluid or nil [Read-only]

Access, set or clear a fluid box. The index must always be in bounds (see LuaFluidBox::operator #); new fluidboxes may not be added or removed using this operator. If the given fluid box doesn't contain any fluid, nil is returned. Similarly, nil can be written to a fluid box to remove all fluid from it.