Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hacked to show patch amounts adjusted for mining productivity researc… #136

Merged
merged 4 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions locale/en/base.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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__'
Expand Down
28 changes: 28 additions & 0 deletions resmon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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_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)
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)
Expand Down Expand Up @@ -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(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)
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)}
Expand Down
23 changes: 23 additions & 0 deletions settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down