A continuation of the abbreviate number topic, how can I convert numbers to have commas? ex: 1000000 > 1,000,000 like in the title. Zednov’s Tycoon Kit’s ConvertComma function is really inefficient and unoptimized.
I believe this should work! Credits to @NuclearTheNoob
function comma_value(amount)
local formatted = amount
while true do
formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
if (k==0) then
break
end
end
return formatted
end
1 Like
It works! Thanks a
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.