This can take a helluva lot of string manipulation and math, which can cause a helluva lot of frustration. I got it though.
06 | decay = decay - (decay*decayfactor) |
07 | stringdecay = tostring (decay) |
09 | if string.find(stringdecay, "." ) then |
10 | local decimal = string.find(stringdecay, "." ) |
11 | local afterdecimal = string.sub(stringdecay, decimal + 2 , string.len(stringdecay)) |
13 | if string.len(afterdecimal) > placesafterdecimal then |
14 | afterdecimal = tostring (math.floor( tonumber (afterdecimal)/ 10 ^(string.len(afterdecimal)-placesafterdecimal))) |
17 | local beforedecimal = string.sub(stringdecay, 1 , decimal) |
19 | local completestring = beforedecimal.. "." ..afterdecimal |
20 | local completenumber = tonumber (completestring) |