Factorio Runtime DocsVersion 2.0.14

ClassLuaFlowStatisticschanged

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.

  • The item production GUI shows "consumption" on the right, thus output describes the item consumption numbers. The same goes for fluid consumption.

  • The kills GUI shows "losses" on the right, so output describes how many of the force's entities were killed by enemies.

  • The electric network GUI shows "power consumption" on the left side, so in this case input describes the power consumption numbers. In addition, electric networks are currently the only ones that utilize the storage part of their statistics, showing accumulator charges to the far right of the GUI.

Members

get_input_count(name) uint64 or double

Gets the total input count for a given prototype.

Gets the total input count for a given prototype.

set_input_count(name, count)

Sets the total input count for a given prototype.

Sets the total input count for a given prototype.

get_output_count(name) uint64 or double

Gets the total output count for a given prototype.

Gets the total output count for a given prototype.

set_output_count(name, count)

Sets the total output count for a given prototype.

Sets the total output count for a given prototype.

get_storage_count(name) newuint64 or double

Gets the total storage count for a given prototype.

Gets the total storage count for a given prototype.

set_storage_count(name, count) new

Sets the total storage count for a given prototype.

Sets the total storage count for a given prototype.

get_flow_count{name=…, category=…, precision_index=…, sample_index?=…, count?=…} changeddouble

Gets the flow count value for the given time frame. [...]

Gets the flow count value for the given time frame. [...]

on_flow(name, count)

Adds a value to this flow statistics.

Adds a value to this flow statistics.

clear()

Reset all the statistics data to 0.

Reset all the statistics data to 0.

input_counts :: R dictionary[string → uint64 or double]

List of input counts indexed by prototype name. [...]

List of input counts indexed by prototype name. [...]

output_counts :: R dictionary[string → uint64 or double]

List of output counts indexed by prototype name. [...]

List of output counts indexed by prototype name. [...]

storage_counts new :: R dictionary[string → uint64 or double]

List of storage counts indexed by prototype name. [...]

List of storage counts indexed by prototype name. [...]

force :: R LuaForce?

The force these statistics belong to. [...]

The force these statistics belong to. [...]

valid :: R boolean

Is this object valid? [...]

Is this object valid? [...]

object_name :: R string

The class name of this object. [...]

The class name of this object. [...]

Methods

get_input_count(name) → uint64 or double

Gets the total input count for a given prototype.

Parameters

name :: string

The prototype name.

The prototype name.


set_input_count(name, count)

Sets the total input count for a given prototype.

Parameters

name :: string

The prototype name.

The prototype name.

count :: uint64 or double

The new count. The type depends on the instance of the statistics.

The new count. The type depends on the instance of the statistics.


get_output_count(name) → uint64 or double

Gets the total output count for a given prototype.

Parameters

name :: string

The prototype name.

The prototype name.


set_output_count(name, count)

Sets the total output count for a given prototype.

Parameters

name :: string

The prototype name.

The prototype name.

count :: uint64 or double

The new count. The type depends on the instance of the statistics.

The new count. The type depends on the instance of the statistics.


get_storage_count(name) → uint64 or doublenew

Gets the total storage count for a given prototype.

Parameters

name :: string

The prototype name.

The prototype name.


set_storage_count(name, count) new

Sets the total storage count for a given prototype.

Parameters

name :: string

The prototype name.

The prototype name.

count :: uint64 or double

The new count. The type depends on the instance of the statistics.

The new count. The type depends on the instance of the statistics.


get_flow_count{name=…, category=…, precision_index=…, sample_index?=…, count?=…} → doublechanged

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

Table with the following fields:
name :: string

The prototype name.

The prototype name.

category :: string

The statistics category to read from. Valid choices are "input", "output" and "storage".

The statistics category to read from. Valid choices are "input", "output" and "storage".

precision_index :: defines.flow_precision_index

The precision to read.

The precision to read.

sample_index :: uint16?

The sample index to read from within the precision range. If not provided, the entire precision range is read. Must be between 1 and 300 where 1 is the most recent sample and 300 is the oldest.

The sample index to read from within the precision range. If not provided, the entire precision range is read. Must be between 1 and 300 where 1 is the most recent sample and 300 is the oldest.

count :: boolean?

If true, the count of items/fluids/entities is returned instead of the per-time-frame value.

If true, the count of items/fluids/entities is returned instead of the per-time-frame value.


on_flow(name, count)

Adds a value to this flow statistics.

Parameters

name :: string

The prototype name.

The prototype name.

count :: float

The count: positive or negative determines if the value goes in the input or output statistics.

The count: positive or negative determines if the value goes in the input or output statistics.


clear()

Reset all the statistics data to 0.

Attributes

input_counts :: Read dictionary[string → uint64 or double]  

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 :: Read dictionary[string → uint64 or double]  

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 :: Read dictionary[string → uint64 or double]   new

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 :: Read LuaForce  ?

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


valid :: Read boolean  

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 :: Read string  

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.

Classes

Concepts

Events

Defines