I was working on a string formation, in terms of shorting money-based values, but I have come to a halt. The basic code below was a quick, rough draft that I created in my head (and it works), but it doesn't "fully" work.
The Code:
function ChangeValue(num)
if num > 999 then -- If num is 1000 or above
num = math.floor(num/1000) ... "K"
elseif num > 999999 then -- if num is 1000000 or above
num = math.floor(num/1000000) ... "M"
end
return num
end
-- EDIT: I CHANGED THE CODE A LITTLE BIT IN TERMS FOR THIS QUESTION.
So, My question is, how do I make this much more efficient and shorten the number based values via default, but also show how much is currently present. (I.e 1,200 --> 1.2K and 1,020 --> 1.02). I do know that I need to use Modulus and string manipulation, but I'm still unclear with that part of Lua at the current minute.
