Control Module - Production - Common functions used to track production of items
-- import the module from the control modules
local Production = require 'modules.control.production' --- @dep modules.control.production
-- This will return the less precise index from the one given
-- this means that one_second will return one_minute or ten_hours will return fifty_hours
-- the other precision work like wise
Production.precision_up(defines.flow_precision_index.one_second)
-- The get production function is used to get production, consumion and net
-- it may be used for any item and with any precision level, use total for total
Production.get_production(game.forces.player, 'iron-plate', defines.flow_precision_index.one_minute)
-- The fluctuations works by compearing recent production with the average over time
-- again any precision may be used, apart from one_thousand_hours as there would be no valid average
Production.get_fluctuations(game.forces.player, 'iron-plate', defines.flow_precision_index.one_minute)
-- ETA is calculated based on what function you use but all share a similar method
-- for production eta it will take current production average given by the precision
-- and work out how many ticks it will require to make the required amount (1000 by default)
Production.get_production_eta(game.forces.player, 'iron-plate', defines.flow_precision_index.one_minute, 250000)
-- Both get_color and format_number are helper functions to help format production stats
-- get_color will return green, orange, red, or grey based on the active_value
-- the passive_value is used when active_value is 0 and can only return orange, red, or grey
Production.get_color(clamp, active_value, passive_value)
utils.color_presets |
util |
precision_up(precision) | Gets the next lesser precision index value, eg 5 seconds -> 1 minute |
precision_down(precision) | Gets the next greater precision index value, eg 1 minute -> 5 seconds |
precision_ticks(precision) | Gets the number of tick that precision is given over, eg 1 minute -> 3600 ticks |
get_production_total(force, item_name) | Returns the production data for the whole game time |
get_production(force, item_name, precision) | Returns the production data for the given precision game time |
get_fluctuations(force, item_name, precision) | Returns the current fluctuation from the average |
get_production_eta(force, item_name, precision[, required=1000]) | Returns the amount of ticks required to produce a certain amount |
get_consumsion_eta(force, item_name, precision[, required=1000]) | Returns the amount of ticks required to consume a certain amount |
get_net_eta(force, item_name, precision[, required=1000]) | Returns the amount of ticks required to produce but not consume a certain amount |
get_color(cutoff, active_value, passive_value) | Returns a color value based on the value that was given |
format_number(value) | Returns three parts used to format a number |
Gets the next lesser precision index value, eg 5 seconds -> 1 minute
Parameters:Gets the next greater precision index value, eg 1 minute -> 5 seconds
Parameters:Gets the number of tick that precision is given over, eg 1 minute -> 3600 ticks
Parameters:Returns the production data for the whole game time
Parameters:Returns the production data for the given precision game time
Parameters:Returns the current fluctuation from the average
Parameters:Returns the amount of ticks required to produce a certain amount
Parameters:Returns the amount of ticks required to consume a certain amount
Parameters:Returns the amount of ticks required to produce but not consume a certain amount
Parameters:Returns a color value based on the value that was given
Parameters: