how can i format a number like this
000,000,001
000,000,002
000,000,003
and so forth
how can i format a number like this
000,000,001
000,000,002
000,000,003
and so forth
First thing would be to pad the number (add zeroes) which you can do by doing something like:
local function padNumber(padAmount, number) -- in our case padAmount would be 9
return string.format(`%.{padAmount}d`, number) -- result of the format string would be '%.9d'
end
local paddedNumber = padNumber(9, 1000) --> 000001000
Next would be to format the number, adding the commas (obtained from here),
local function numWithCommas(n)
return n:reverse():gsub("(%d%d%d)","%1,"):gsub(",(%-?)$","%1"):reverse()
end
paddedNumber = numWithCommas(paddedNumber) --> should now be 000,001,000
So the final script would be something like:
local function formatPaddedNumber(padAmount, number)
return string.format(`%.{padAmount}d`, number):reverse():gsub("(%d%d%d)","%1,"):gsub(",(%-?)$","%1"):reverse()
end
print(formatPaddedNumber(9, 1000)) --> 000,001,000
Thank you so much! It works well
just a reminder your ui looks amazing
what i dont get is why you want a system like this. it doesnt look clean
how else should i do it? . . . . .
as a normal person would bro just show the number by itself
I agree with you, it also implies that you have a coin limit of 999,999,999 (or at least by the looks of the gui) But everyone has their own opinions.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.