mirror of
https://github.com/peter-tanner/Pollution-statistics.git
synced 2024-11-30 05:50:16 +08:00
initial release: 0.1.0
This commit is contained in:
parent
abdb0fe9e8
commit
5193e60aa5
41
Pollution_statistics/control.lua
Normal file
41
Pollution_statistics/control.lua
Normal file
|
@ -0,0 +1,41 @@
|
|||
local display_rate = settings.global["stat-display-rate"].value
|
||||
local polling_rate = settings.global["stat-polling-rate"].value
|
||||
local scale_constant = 1/(settings.global["stat-scale-constant"].value)
|
||||
|
||||
if display_rate == polling_rate then
|
||||
stat_error = true
|
||||
end
|
||||
script.on_nth_tick(display_rate, function()
|
||||
if global.stat_init == false then
|
||||
global.stats_player_stats.on_flow("pollution",global.stat_new_pollution)
|
||||
end
|
||||
end)
|
||||
|
||||
script.on_nth_tick(polling_rate, function()
|
||||
if game.forces["enemy"] and game.forces["player"] and not stat_error then
|
||||
if global.stat_init == true then
|
||||
global.stats_player_stats = game.forces['player'].item_production_statistics
|
||||
global.last_evo = game.forces['enemy'].evolution_factor_by_pollution
|
||||
global.stat_init = false
|
||||
end
|
||||
local evo = game.forces['enemy'].evolution_factor_by_pollution
|
||||
local new_pollution = math.floor((evo - global.last_evo)*10^6) --1000000000; tick= 240
|
||||
global.stat_new_pollution = new_pollution*(240/polling_rate)*display_rate*scale_constant
|
||||
global.last_pollution = new_pollution
|
||||
global.last_evo = evo
|
||||
else
|
||||
if stat_error then
|
||||
game.print("ERROR: POLLING RATE MUST NOT EQUAL DISPLAY RATE")
|
||||
else
|
||||
game.print("ERROR: The pollution statistics mod only works in singleplayer or in multiplayer for only the 'player' force.")
|
||||
game.print("Player or enemy force not found.")
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
script.on_init(function()
|
||||
global.stat_init = true
|
||||
global.last_evo = 0
|
||||
global.last_pollution = 0
|
||||
global.stat_new_pollution = 0
|
||||
end)
|
10
Pollution_statistics/info.json
Normal file
10
Pollution_statistics/info.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "Pollution_statistics",
|
||||
"version": "0.1.0",
|
||||
"factorio_version": "0.17",
|
||||
"title": "Pollution statistics",
|
||||
"author": "npc_strider(morley376)",
|
||||
"contact": "",
|
||||
"homepage": "http://steamcommunity.com/id/morley376",
|
||||
"description": "Emulates the pollution statistics in the Factorio campaign. The resulting value is the relative pollution value, not an absolute one. Note that this mod only works with two forces: player and enemy(biters), and biters must be present to calculate the pollution statistic - it is not suitable with multiple factions."
|
||||
}
|
9
Pollution_statistics/locale/en/base.cfg
Normal file
9
Pollution_statistics/locale/en/base.cfg
Normal file
|
@ -0,0 +1,9 @@
|
|||
[mod-setting-name]
|
||||
stat-display-rate=Graph refresh rate
|
||||
stat-polling-rate=Pollution polling frequency
|
||||
stat-scale-constant=Pollution graph scale constant
|
||||
|
||||
[mod-setting-description]
|
||||
stat-display-rate=(Default 15, Min 1, Max INF.) How often (in ticks) does the mod graph the result data. Note that this option must not equal the lower option. At 1, the graph is perfect to the data supplied, but has a large UPS cost. 60 is a good starting point for UPS efficiency. Campaign default: 240.
|
||||
stat-polling-rate=(Default 180, Min 1, Max INF.) How often (in ticks) does the mod poll the pollution level. Note that this option must not equal the upper option. Higher value generate less accurate data, but have less of a UPS cost. Campaign default: 240.
|
||||
stat-scale-constant=(Default 400) Affects the vertical scale of the pollution graph. Note that changing this value in an existing save will not affect data generated after the change, meaning it will be distorted in comparison to the current scaled data. The scale of the graph is a reciprocal of this value. Campaign default: 800
|
26
Pollution_statistics/settings.lua
Normal file
26
Pollution_statistics/settings.lua
Normal file
|
@ -0,0 +1,26 @@
|
|||
data:extend(
|
||||
{
|
||||
{
|
||||
type = "int-setting",
|
||||
name = "stat-display-rate",
|
||||
setting_type = "runtime-global",
|
||||
default_value = 15,
|
||||
minimum_value = 1,
|
||||
order = "stat-a"
|
||||
},
|
||||
{
|
||||
type = "int-setting",
|
||||
name = "stat-polling-rate",
|
||||
setting_type = "runtime-global",
|
||||
default_value = 180,
|
||||
minimum_value = 1,
|
||||
order = "stat-b"
|
||||
},
|
||||
{
|
||||
type = "int-setting",
|
||||
name = "stat-scale-constant",
|
||||
setting_type = "runtime-global",
|
||||
default_value = 400,
|
||||
order = "stat-c"
|
||||
}
|
||||
})
|
BIN
Pollution_statistics/thumbnail.png
Normal file
BIN
Pollution_statistics/thumbnail.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
Loading…
Reference in New Issue
Block a user