1. Add this line to your addon's TOC file:
Code:
## SavedVariables: MyCustomTextFormat
2. Modify your addon's Lua code like so:
Code:
MyCustomTextFormat = "VALUE"
hooksecurefunc("TextStatusBar_UpdateTextStringWithValues", function(statusBar, fontString, value, valueMin, valueMax)
local str, val
if MyCustomTextFormat == "PERCENT" then
-- Show the value as a percent
str, val = "%.0f%%", value / valueMax * 100
elseif value >= 1e10 then
-- Shorten 10,000,000,000+ like 12b
str, val = "%.0fb", value / 1e9
elseif value >= 1e9 then
-- Shorten 1,000,000,000+ like 8.3b
str, val = "%.1fb", value / 1e9
elseif value >= 1e7 then
-- Shorten 10,000,000+ like 14m
str, val = "%.1fm", value / 1e6
elseif value >= 1e6 then
-- Shorten 1,000,000+ like 7.4m
str, val = "%.2fm", value / 1e6
elseif value >= 1e5 then
-- Shorten 100,000+ like 84k
str, val = "%.0fk", value / 1e3
elseif value >= 1e3 then
-- Shorten 1,000+ like 2.5k
str, val = "%.1fk", value / 1e3
else
-- Don't shorten under 1,000
str, val = "%d", value
end
fontString:SetFormattedText(str, val)
end)
SLASH_CUSTOMSHORTTEXT1 = "/pct"
SlashCmdList.CUSTOMSHORTTEXT = function()
MyCustomTextFormat = MyCustomTextFormat == "VALUE" and "PERCENT" or "VALUE"
print("Short text now showing", strlower(MyCustomTextFormat))
end
If you don't want it to remember your preference between reloads or logouts, just skip Step 1.