From 5193e60aa5d3c8bb99d4d9d0496193330c70518b Mon Sep 17 00:00:00 2001 From: npc-strider Date: Sat, 2 Mar 2019 17:42:32 +0800 Subject: [PATCH] initial release: 0.1.0 --- Pollution_statistics/control.lua | 41 ++++++++++++++++++++++++ Pollution_statistics/info.json | 10 ++++++ Pollution_statistics/locale/en/base.cfg | 9 ++++++ Pollution_statistics/settings.lua | 26 +++++++++++++++ Pollution_statistics/thumbnail.png | Bin 0 -> 2077 bytes 5 files changed, 86 insertions(+) create mode 100644 Pollution_statistics/control.lua create mode 100644 Pollution_statistics/info.json create mode 100644 Pollution_statistics/locale/en/base.cfg create mode 100644 Pollution_statistics/settings.lua create mode 100644 Pollution_statistics/thumbnail.png diff --git a/Pollution_statistics/control.lua b/Pollution_statistics/control.lua new file mode 100644 index 0000000..b71f280 --- /dev/null +++ b/Pollution_statistics/control.lua @@ -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) \ No newline at end of file diff --git a/Pollution_statistics/info.json b/Pollution_statistics/info.json new file mode 100644 index 0000000..7885ef3 --- /dev/null +++ b/Pollution_statistics/info.json @@ -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." +} \ No newline at end of file diff --git a/Pollution_statistics/locale/en/base.cfg b/Pollution_statistics/locale/en/base.cfg new file mode 100644 index 0000000..1b5c589 --- /dev/null +++ b/Pollution_statistics/locale/en/base.cfg @@ -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 \ No newline at end of file diff --git a/Pollution_statistics/settings.lua b/Pollution_statistics/settings.lua new file mode 100644 index 0000000..614eba5 --- /dev/null +++ b/Pollution_statistics/settings.lua @@ -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" + } +}) \ No newline at end of file diff --git a/Pollution_statistics/thumbnail.png b/Pollution_statistics/thumbnail.png new file mode 100644 index 0000000000000000000000000000000000000000..801ae52d3ce8c531b77b1504b9e8ff67fec67719 GIT binary patch literal 2077 zcmV+&2;%pNP)M+={ZIT^ zzls0`oLs!7X}VGe2cE5s4JQ%n*=%;iW?4g|zR=s-Tk`w;+Q7g-mi?s~Ha1nrmX9cqG;{N^ne`D38 zF53T&fQOHMY_(dG80aGURvCp;f)>lfVQFDuL4Eb=l`ox6J5HQ95jc15T&Tal-%A$i z2L}fmnAz&??k*tGMwzvsG26fQ*1%Z3_?%8*DcmKf4=P=j< z83!L})LeuEZjdhzG*v#>Pe}kx0bJ*oxcj-Y*mi z70P5mT)BSzx({M%oHai`pLqTH^(HPe!0Ob16P)ep>iX{F$&(@K=^+RwMh(6*5Sn`I z*fEWL8~gQ2ol9k0tWa!_#X6vF1cs-`FzI2#Do@&Mim_D7E5Cku^(`-a3~^eY;SKDmX?-2 zLF5zSP3QA@b8v95=jhR+0Wx4Guq@y0kcIf;$B!4VojN3N=%_)>T`UcU7E!A>cc76bf~!)(5*gda&JNGB=*Sib1o}WPnR9?F znfScQT3K0ni|zeG0=I768tVxLe}@qbp(sy&{&|!jM|tD`4fLkrVYo^p z1}W7Lq(!8M9g#|>> zas*YRG&MRRxwW+=y5%`o2aQ7l(^FGtBLf42C|6xvTnt~mdi6UZ=oakx(1v51-EP-O zzXuJdqAeSZhMV`@qAN(P9YN~I!L+d;XXm0qj3cA6N6tOGSQ%oi*Mh&+0Ev1f5o3bxsyN-7$(gVH*emYz}Oi%2}?MrAg=PMQ>VnJ z?ZLQLbOwAq&}y7cYiz6u_|`v?-5C+m+Bm3&H{FE=pq~a-9~e;dcTVHsWMM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