Originally Posted by Ammako
This is something I do to format numbers and group into thousands/millions.
lua Code:
local function formatPlayerNumbers(amount) local formatted, k = amount if amount >= 100000 and amount < 100000000 then formatted = string.sub(formatted, 0, (string.len(formatted) - 3)) .. " K" elseif amount >= 100000000 then formatted = string.sub(formatted, 0, (string.len(formatted) - 6)) .. " M" else while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if (k==0) then break end end end return formatted end
Of you're, you'll have to tweak the amounts at lines 4 and 6 to get it to shorten 5,000,000 as 5M rather than 5,000K, but you get the point.
|
hikokun, while debugging I suggest in line 16 of this code to add print(formatted). And in your code, in line 11 to replace curhp with formatPlayerNumbers(curhp), and maxhp with formatPlayerNumbers(maxhp).
Fizzlemizz, thanks for explanation but I meant to ask what the code accomplishes instead of what it does.
But won't this become unneeded after 7.3.5 with ilvl (and stat) squishes?