Here's a version that will use your CVar setting instead, as suggested by Semlar. I also converted the growing if-else chain into an easier-to-maintain indexed table loop:
Code:
local shorts = {
{ 1e10, 1e9, "%.0fb" }, -- 10b+ as 12b
{ 1e9, 1e9, "%.1fb" }, -- 1b+ as 8.3b
{ 1e7, 1e6, "%.0fm" }, -- 10m+ as 14m
{ 1e6, 1e6, "%.1fm" }, -- 1m+ as 7.4m
{ 1e5, 1e3, "%.0fk" }, -- 100k+ as 840k
{ 1e3, 1e3, "%.1fk" }, -- 1k+ as 2.5k
{ 0, 1, "%d" }, -- < 1k as 974
}
for i = 1, #shorts do
shorts[i][4] = shorts[i][3] .. " (%.0f%%)"
end
hooksecurefunc("TextStatusBar_UpdateTextStringWithValues", function(statusBar, fontString, value, valueMin, valueMax)
local style = GetCVar("statusTextDisplay")
if style == "PERCENT" then
return fontString:SetFormattedText("%.0f%%", value / valueMax * 100)
end
for i = 1, #shorts do
local t = shorts[i]
if value >= t[1] then
return style == "BOTH"
and fontString:SetFormattedText(t[4], value / t[2], value / valueMax * 100)
or fontString:SetFormattedText(t[3], value / t[2])
end
end
end)