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.
output describes the item consumption numbers. The same goes for fluid consumption.output describes how many of the force's entities were killed by enemies.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.Dict<string, uint64 | double>unknownfalseList of input counts indexed by prototype name. Represents the data that is shown on the left side of the GUI for the given statistics.
Dict<string, uint64 | double>unknownfalseList 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.
Dict<string, uint64 | double>unknownfalseList 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.
LuaForceunknowntrueThe force these statistics belong to. nil for pollution statistics.
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.
LuaFlowStatistics.get_input_count(id: FlowStatisticsID) -> uint64 | double
flowStatistics.get_input_count(id)
takes_table: falsetable_optional: falseGets the total input count for a given prototype.
id: FlowStatisticsID — The prototype ID.uint64 | doubleLuaFlowStatistics.set_input_count(id: FlowStatisticsID, count: uint64 | double)
flowStatistics.set_input_count(id, count)
takes_table: falsetable_optional: falseSets the total input count for a given prototype.
id: FlowStatisticsID — The prototype ID.count: uint64 | double — The new count. The type depends on the instance of the statistics.LuaFlowStatistics.get_output_count(id: FlowStatisticsID) -> uint64 | double
flowStatistics.get_output_count(id)
takes_table: falsetable_optional: falseGets the total output count for a given prototype.
id: FlowStatisticsID — The prototype ID.uint64 | doubleLuaFlowStatistics.set_output_count(id: FlowStatisticsID, count: uint64 | double)
flowStatistics.set_output_count(id, count)
takes_table: falsetable_optional: falseSets the total output count for a given prototype.
id: FlowStatisticsID — The prototype ID.count: uint64 | double — The new count. The type depends on the instance of the statistics.LuaFlowStatistics.get_storage_count(id: FlowStatisticsID) -> uint64 | double
flowStatistics.get_storage_count(id)
takes_table: falsetable_optional: falseGets the total storage count for a given prototype.
id: FlowStatisticsID — The prototype ID.uint64 | doubleLuaFlowStatistics.set_storage_count(id: FlowStatisticsID, count: uint64 | double)
flowStatistics.set_storage_count(id, count)
takes_table: falsetable_optional: falseSets the total storage count for a given prototype.
id: FlowStatisticsID — The prototype ID.count: uint64 | double — The new count. The type depends on the instance of the statistics.LuaFlowStatistics.get_flow_count{ name: FlowStatisticsID, category: string, precision_index: defines.flow_precision_index, sample_index?: uint16, count?: boolean } -> double
flowStatistics.get_flow_count{ name="name", category=category, precision_index=precision_index }
takes_table: truetable_optional: falseGets 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.
name: FlowStatisticsID — The prototype ID.category: string — The statistics category to read from. Valid choices are "input", "output" and "storage".precision_index: defines.flow_precision_index — 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.count?: boolean — If true, the count of items/fluids/entities is returned instead of the per-time-frame value.doubleLuaFlowStatistics.on_flow(id: FlowStatisticsID, count: float)
flowStatistics.on_flow(id, count)
takes_table: falsetable_optional: falseAdds a value to this flow statistics.
id: FlowStatisticsID — The prototype ID.count: float — The count: positive or negative determines if the value goes in the input or output statistics.LuaFlowStatistics.clear()
flowStatistics.clear()
takes_table: falsetable_optional: falseReset all the statistics data to 0.