Title says it all. I convert 10,000,000 to 10M, how would I convert it to 10,000,000 again?
How did you convert it to begin with? If you didn’t write that code, you should ask the person who wrote it first.
local abs = {'K','M','B','T','Qd','Qn', 'Sx', 'Sp', 'O', 'n', 'D'}
function addtitle(n)
if not n then
return "cannot compute"
end
if n == "0" or n == 0 then
return 0
end
n = tonumber(n)
local numb = math.abs(tonumber(n))
local i = math.min(math.floor(math.log10(numb)/3), #abs)
local suffix = tonumber(i) > 0 and abs[i] or ''
local num = tostring(numb/10^(3*i))
local format = num:match('%d+.%d%d')
format = format or num
if n < 0 then
return "-" .. format..suffix
end
return format..suffix
end
This converts it to 10T. But if a player puts 10T or 10B in a text label, I want this to change into a number again
this is probably not effecient, but just use if statements, times everything ending with K by 1,000, everything ending with M by 1,000,000, and so on
you could also reverse the code you used here but personally i feel like if statements works fine
So like:
if amount:match('K') then
local a = amount:sub(1, #amount - 1)
return a * 1000 -- this should return like 1000 if i do 1K
end
yea, something like that
(do it for all the symbols)
bruh character limit
Alright, thanks.
character limit