Control Module - Production - Common functions used to track production of items
-- import the module from the control modules
local Production = require '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)
resources.color_presets | Provides colors for Production.get_color |
util | Provides format_number function to add surfixs |
precision_up (precision) | Gets the next lesser precision index value, eg 1 second -> 1 minute |
precision_down (precision) | Gets the next greater precision index value, eg 1 minute -> 1 second |
precision_ticks (precision) | Gets the number of tick that precision is given over, eg 1 minute -> 60 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 (clamp, active_value, passive_value) | Returns a color value bassed on the value that was given |
format_number (value) | Returns three parts used to format a number |
Provides colors for Production.get_color
Provides format_number function to add surfixs
Gets the next lesser precision index value, eg 1 second -> 1 minute
Parameters:Gets the next greater precision index value, eg 1 minute -> 1 second
Parameters:Gets the number of tick that precision is given over, eg 1 minute -> 60 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 bassed on the value that was given
Parameters: