Home

LuaFlowStatistics

Encapsulates statistic data for different parts of the game.

In the context of flow statistics, input, output and storage describe in which position of the associated GUI the values are shown. Input values are shown on the far left side, output values to the immediate right, and storage values (if present) to the far right.

Attributes

input_counts

List of input counts indexed by prototype name. Represents the data that is shown on the left side of the GUI for the given statistics.

output_counts

List of output counts indexed by prototype name. Represents the data that is shown in the middle of the GUI for electric networks and on the right side for all other statistics types.

storage_counts

List of storage counts indexed by prototype name. Represents the data that is shown on the right side of the GUI for electric networks. For other statistics types these values are currently unused and hidden.

force

The force these statistics belong to. nil for pollution statistics.

valid

Is 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.

object_name

The 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.

Methods

get_input_count

LuaFlowStatistics.get_input_count(id: FlowStatisticsID) -> uint64 | double

Call As

flowStatistics.get_input_count(id)

Call Convention

Gets the total input count for a given prototype.

Parameters

Returns

set_input_count

LuaFlowStatistics.set_input_count(id: FlowStatisticsID, count: uint64 | double)

Call As

flowStatistics.set_input_count(id, count)

Call Convention

Sets the total input count for a given prototype.

Parameters

get_output_count

LuaFlowStatistics.get_output_count(id: FlowStatisticsID) -> uint64 | double

Call As

flowStatistics.get_output_count(id)

Call Convention

Gets the total output count for a given prototype.

Parameters

Returns

set_output_count

LuaFlowStatistics.set_output_count(id: FlowStatisticsID, count: uint64 | double)

Call As

flowStatistics.set_output_count(id, count)

Call Convention

Sets the total output count for a given prototype.

Parameters

get_storage_count

LuaFlowStatistics.get_storage_count(id: FlowStatisticsID) -> uint64 | double

Call As

flowStatistics.get_storage_count(id)

Call Convention

Gets the total storage count for a given prototype.

Parameters

Returns

set_storage_count

LuaFlowStatistics.set_storage_count(id: FlowStatisticsID, count: uint64 | double)

Call As

flowStatistics.set_storage_count(id, count)

Call Convention

Sets the total storage count for a given prototype.

Parameters

get_flow_count

LuaFlowStatistics.get_flow_count{ name: FlowStatisticsID, category: string, precision_index: defines.flow_precision_index, sample_index?: uint16, count?: boolean } -> double

Call As

flowStatistics.get_flow_count{ name="name", category=category, precision_index=precision_index }

Call Convention

Gets the flow count value for the given time frame. If sample_index is not provided, then the value returned is the average across the provided precision time period. These are the values shown in the bottom section of the statistics GUIs.

Use sample_index to access the data used to generate the statistics graphs. Each precision level contains 300 samples of data so at a precision of 1 minute, each sample contains data averaged across 60s / 300 = 0.2s = 12 ticks.

All return values are normalized to be per-tick for electric networks and per-minute for all other types.

Parameters

Returns

on_flow

LuaFlowStatistics.on_flow(id: FlowStatisticsID, count: float)

Call As

flowStatistics.on_flow(id, count)

Call Convention

Adds a value to this flow statistics.

Parameters

clear

LuaFlowStatistics.clear()

Call As

flowStatistics.clear()

Call Convention

Reset all the statistics data to 0.