From e9c2a437d4787caf3513edac751d83873b0cf3e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20A=2E=20Erhard?= Date: Tue, 26 Oct 2021 14:33:50 +0200 Subject: [PATCH 1/4] Hacked to show patch amounts adjusted for mining productivity researched. --HG-- branch : jae --- locale/en/base.cfg | 8 ++++++++ resmon.lua | 28 ++++++++++++++++++++++++++++ settings.lua | 23 +++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/locale/en/base.cfg b/locale/en/base.cfg index f7fdfc7..f3c676e 100644 --- a/locale/en/base.cfg +++ b/locale/en/base.cfg @@ -43,6 +43,9 @@ YARM-map-markers=Enable map markers YARM-order-by=Order resource list by YARM-site-prefix-with-surface=Prefix the site name with the surface name YARM-debug-profiling=(Debug) Enable profiling output +YARM-adjust-for-productivity=Adjust values for productivity researched +YARM-productivity-show-raw-and-adjusted=Show both raw and adjusted values +YARM-productivity-parentheses-part-is=Which value is in parentheses [mod-setting-description] YARM-ticks-between-checks=When a resource site is being monitored, the amount of resources in it is only updated once every N game ticks (60 ticks = 1 second), based on this value. Increase to hopefully improve UPS, at the cost of needing longer to update a site's estimates. @@ -53,12 +56,17 @@ YARM-warn-percent=The percentage of remaining resources that will alert the play YARM-order-by=Change the display order of sites in the YARM list. YARM-site-prefix-with-surface=Prefix the surface name to the site name. Useful for maps with multiple surfaces. YARM-debug-profiling=When enabled, outputs some information about tick timing to the player output and factorio-current.log. +YARM-adjust-for-productivity=Amounts are shown adjusted by mining productivity research. +YARM-productivity-show-raw-and-adjusted=Amounts show both raw amount and amount adjusted by mining productivity research, one of them in parentheses (default: show the raw amount in parentheses). +YARM-productivity-parentheses-part-is=Change which amount (raw or adjusted for mining productivity) is shown in parentheses. [string-mod-setting] YARM-order-by-percent-remaining=remaining percentage YARM-order-by-ore-type=ore type, then remaining percentage YARM-order-by-ore-count=ore count remaining YARM-order-by-etd=estimated time to depletion +YARM-productivity-parentheses-part-is-adjusted=adjusted for productivity research +YARM-productivity-parentheses-part-is-raw=raw [YARM-tooltips] rename-site-named=Rename site '__1__' diff --git a/resmon.lua b/resmon.lua index b9261d3..4eda585 100644 --- a/resmon.lua +++ b/resmon.lua @@ -517,6 +517,19 @@ function resmon.update_chart_tag(site) end local display_value = format_number_si(site.amount) + if settings.global["YARM-adjust-for-productivity"] then + local site_amount = display_value + local site_amount_w_productivity = format_number(site.amount * (1 + player.force.mining_drill_productivity_bonus)) + if settings.global["YARM-productivity-show-raw-and-adjusted"] then + if settings.global["YARM-productivity-parentheses-part-is"] == "adjusted" then + display_value = string.format("%s (%s)", site_amount, site_amount_w_productivity) + else + display_value = string.format("%s (%s)", site_amount_w_productivity, site_amount) + end + else + display_value = site_amount_w_productivity + end + end local entity_prototype = game.entity_prototypes[site.ore_type] if resmon.is_endless_resource(site.ore_type, entity_prototype) then display_value = string.format("%.1f%%", site.remaining_permille / 10) @@ -919,6 +932,21 @@ function resmon.print_single_site(site, player, sites_gui, player_data) el.style.font_color = color local display_amount = format_number(site.amount) + if settings.global["YARM-adjust-for-productivity"] then + local site_amount = display_amount + local site_amount_w_productivity = format_number(site.amount * (1 + player.force.mining_drill_productivity_bonus)) + if settings.global["YARM-productivity-show-raw-and-adjusted"] then + if settings.global["YARM-productivity-parentheses-part-is"] == "adjusted" then + display_amount = string.format("%s (%s)", site_amount, site_amount_w_productivity) + else + display_amount = string.format("%s (%s)", site_amount_w_productivity, site_amount) + end + else + display_amount = site_amount_w_productivity + end + -- FIXME: honor the "show both" setting + end + local entity_prototype = game.entity_prototypes[site.ore_type] if resmon.is_endless_resource(site.ore_type, entity_prototype) then display_amount = {"YARM-infinite-entity-count", format_number(site.entity_count)} diff --git a/settings.lua b/settings.lua index 5316d50..d298fb0 100644 --- a/settings.lua +++ b/settings.lua @@ -49,6 +49,29 @@ data:extend({ order = "zz[debug]", default_value = false, }, + + { + type = "bool-setting", + name = "YARM-adjust-for-productivity", + setting_type = "runtime-global", + order = "c", + default_value = "false", + }, + { + type = "bool-setting", + name = "YARM-productivity-show-raw-and-adjusted", + setting_type = "runtime-global", + order = "d", + default_value = "false", + }, + { + type = "string-setting", + name = "YARM-productivity-parentheses-part-is", + setting_type = "runtime-global", + order = "e", + default_value = "adjusted", + allowed_values = {"adjusted", "raw"} + }, -- Per user settings { From ad53b6f768266878f9bbd8b10b2eaa398a35ce03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20A=2E=20Erhard?= Date: Tue, 26 Oct 2021 15:57:30 +0200 Subject: [PATCH 2/4] Forgot to adjust code I copy/pasted. Fixed. --HG-- branch : jae --- resmon.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resmon.lua b/resmon.lua index 4eda585..1819d5c 100644 --- a/resmon.lua +++ b/resmon.lua @@ -519,7 +519,7 @@ function resmon.update_chart_tag(site) local display_value = format_number_si(site.amount) if settings.global["YARM-adjust-for-productivity"] then local site_amount = display_value - local site_amount_w_productivity = format_number(site.amount * (1 + player.force.mining_drill_productivity_bonus)) + local site_amount_w_productivity = format_number(site.amount * (1 + site.force.mining_drill_productivity_bonus)) if settings.global["YARM-productivity-show-raw-and-adjusted"] then if settings.global["YARM-productivity-parentheses-part-is"] == "adjusted" then display_value = string.format("%s (%s)", site_amount, site_amount_w_productivity) From e25c4806a512c342b9a0de3bbf6eedd946db7671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20A=2E=20Erhard?= Date: Tue, 26 Oct 2021 17:16:47 +0200 Subject: [PATCH 3/4] Gah, I had update_chart_tag with the correct format_number_si but somehow lost it. --HG-- branch : jae --- resmon.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resmon.lua b/resmon.lua index 1819d5c..ebf4d8c 100644 --- a/resmon.lua +++ b/resmon.lua @@ -519,7 +519,7 @@ function resmon.update_chart_tag(site) local display_value = format_number_si(site.amount) if settings.global["YARM-adjust-for-productivity"] then local site_amount = display_value - local site_amount_w_productivity = format_number(site.amount * (1 + site.force.mining_drill_productivity_bonus)) + local site_amount_w_productivity = format_number_si(site.amount * (1 + site.force.mining_drill_productivity_bonus)) if settings.global["YARM-productivity-show-raw-and-adjusted"] then if settings.global["YARM-productivity-parentheses-part-is"] == "adjusted" then display_value = string.format("%s (%s)", site_amount, site_amount_w_productivity) From 6aa9c34a2bde91d15f6b6ec8da480e3174a2b5ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20A=2E=20Erhard?= Date: Tue, 26 Oct 2021 18:10:39 +0200 Subject: [PATCH 4/4] Values shouldn't have decimal parts, so use math.floor for adjusted value. --HG-- branch : jae --- resmon.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resmon.lua b/resmon.lua index ebf4d8c..45f093b 100644 --- a/resmon.lua +++ b/resmon.lua @@ -934,7 +934,7 @@ function resmon.print_single_site(site, player, sites_gui, player_data) local display_amount = format_number(site.amount) if settings.global["YARM-adjust-for-productivity"] then local site_amount = display_amount - local site_amount_w_productivity = format_number(site.amount * (1 + player.force.mining_drill_productivity_bonus)) + local site_amount_w_productivity = format_number(math.floor(site.amount * (1 + player.force.mining_drill_productivity_bonus))) if settings.global["YARM-productivity-show-raw-and-adjusted"] then if settings.global["YARM-productivity-parentheses-part-is"] == "adjusted" then display_amount = string.format("%s (%s)", site_amount, site_amount_w_productivity)