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.
LuaEntityunknownfalseThe entity that owns this fluidbox.
booleanunknownfalseIs this object valid? This Lua object holds a reference to an object within the game engine. It is possible that the game-engine object is removed whilst a mod still holds the corresponding Lua object. If that happens, the object becomes invalid, i.e. this attribute will be false. Mods are advised to check for object validity if any change to the game state might have occurred between the creation of the Lua object and its access.
stringunknownfalseThe class name of this object. Available even when valid is false. For LuaStruct objects it may also be suffixed with a dotted path to a member of the struct.
LuaFluidBox.get_prototype(index: uint32) -> LuaFluidBoxPrototype | Array<LuaFluidBoxPrototype>
fluidBox.get_prototype(index)
takes_table: falsetable_optional: falseThe prototype of this fluidbox index. If this is used on a fluidbox of a crafting machine which due to recipe was created by merging multiple prototypes, a table of prototypes that were merged will be returned instead
index: uint32LuaFluidBoxPrototype | Array<LuaFluidBoxPrototype>LuaFluidBox.get_capacity(index: uint32) -> double
fluidBox.get_capacity(index)
takes_table: falsetable_optional: falseThe capacity of the given fluidbox segment.
index: uint32doubleLuaFluidBox.get_connections(index: uint32) -> Array<LuaFluidBox>
fluidBox.get_connections(index)
takes_table: falsetable_optional: falseThe fluidboxes to which the fluidbox at the given index is connected.
index: uint32Array<LuaFluidBox>LuaFluidBox.get_pipe_connections(index: uint32) -> Array<PipeConnection>
fluidBox.get_pipe_connections(index)
takes_table: falsetable_optional: falseGet the fluid box's connections and associated data.
index: uint32Array<PipeConnection>LuaFluidBox.get_filter(index: uint32) -> FluidBoxFilter?
fluidBox.get_filter(index)
takes_table: falsetable_optional: falseGet a fluid box filter
index: uint32 — The index of the filter to get.FluidBoxFilter? — The filter at the requested index, or nil if there isn't one.LuaFluidBox.set_filter(index: uint32, filter: FluidBoxFilterSpec | nil) -> boolean
fluidBox.set_filter(index, filter)
takes_table: falsetable_optional: falseSet a fluid box filter.
Some entities cannot have their fluidbox filter set, notably fluid wagons and crafting machines.
index: uint32 — The index of the filter to set.filter: FluidBoxFilterSpec | nil — The filter to set. Setting nil clears the filter.boolean — Whether the filter was set successfully.LuaFluidBox.get_locked_fluid(index: uint32) -> string?
fluidBox.get_locked_fluid(index)
takes_table: falsetable_optional: falseReturns the fluid the fluidbox is locked onto
index: uint32string? — nil if the fluidbox is not locked to any fluid.LuaFluidBox.get_fluid_segment_id(index: uint32) -> uint32?
fluidBox.get_fluid_segment_id(index)
takes_table: falsetable_optional: falseGets the unique ID of the fluid segment this fluid box belongs to. May return nil for fluid wagon, fluid turret's internal buffer or a fluidbox which does not belong to a fluid segment.
index: uint32uint32?LuaFluidBox.get_fluid_segment_contents(index: uint32) -> Dict<string, uint32>?
fluidBox.get_fluid_segment_contents(index)
takes_table: falsetable_optional: falseGets counts of all fluids in the fluid segment. May return nil for fluid wagon, fluid turret's internal buffer, or a fluidbox which does not belong to a fluid segment.
Note that this method only ever returns one fluid, since fluids can't be mixed anymore.
index: uint32Dict<string, uint32>? — The counts, indexed by fluid name.LuaFluidBox.get_fluid_segment_extent_bounding_box(index: uint32) -> BoundingBox?
fluidBox.get_fluid_segment_extent_bounding_box(index)
takes_table: falsetable_optional: falseGets the current extent bounding box of the fluid segment this fluid box belongs to. May return nil for fluid wagon, fluid turret's internal buffer, or a fluidbox which does not belong to a fluid segment.
index: uint32BoundingBox?LuaFluidBox.flush(index: uint32, fluid?: FluidID) -> Dict<string, FluidAmount>
fluidBox.flush(index, fluid)
takes_table: falsetable_optional: falseFlushes all fluid from this fluidbox and its fluid system.
index: uint32fluid?: FluidID — If provided, only this fluid is flushed.Dict<string, FluidAmount> — The removed fluid.LuaFluidBox.add_linked_connection(this_linked_connection_id: uint32, other_entity: LuaEntity, other_linked_connection_id: uint32)
fluidBox.add_linked_connection(this_linked_connection_id, other_entity, other_linked_connection_id)
takes_table: falsetable_optional: falseRegisters a linked connection between this entity and other entity. Because entity may have multiple fluidboxes, each with multiple connections that could be linked, a unique value for this and other linked_connection_id may need to be given.
It may happen a linked connection is not established immediately due to crafting machines being possible to not have certain fluidboxes exposed at a given point in time, but once they appear (due to recipe changes that would use them) they will be linked. Linked connections are persisted as (this_entity, this_linked_connection_id, other_entity, other_linked_connection_id) so if a pipe connection definition's value of linked_connection_id changes existing connections may not restore correct connections.
Every fluidbox connection that was defined in prototypes as connection_type=="linked" may be linked to at most 1 other fluidbox. When trying to connect already used connection, previous connection will be removed.
Linked connections cannot go to the same entity even if they would be part of other fluidbox.
this_linked_connection_id: uint32other_entity: LuaEntityother_linked_connection_id: uint32LuaFluidBox.remove_linked_connection(this_linked_connection_id: uint32)
fluidBox.remove_linked_connection(this_linked_connection_id)
takes_table: falsetable_optional: falseRemoves linked connection record. If connected, other end will be also removed.
this_linked_connection_id: uint32LuaFluidBox.get_linked_connection(this_linked_connection_id: uint32) -> LuaEntity?, uint32?
fluidBox.get_linked_connection(this_linked_connection_id)
takes_table: falsetable_optional: falseReturns other end of a linked connection.
this_linked_connection_id: uint32LuaEntity? — Other entity to which a linked connection was madeuint32? — linked_connection_id on other entityLuaFluidBox.get_linked_connections() -> Array<FluidBoxConnectionRecord>
fluidBox.get_linked_connections()
takes_table: falsetable_optional: falseReturns list of all linked connections registered for this entity.
Array<FluidBoxConnectionRecord>