I'm not here to brag but I wrote a very small program that can round up numbers with decimals. It is an extension of BlueTaslem's formula (or something): https://scriptinghelpers.org/questions/4850/how-do-i-round-numbers-in-lua-answered
The program consists of 2 arguments/parameters. The number (x) and the optional argument to round the number up to a certain amount of decimals.
Here is the code:
function round(x, decimalPlaces) decimalPlaces = decimalPlaces or 0 -- decimalPlaces is an optional argument/parameter. Defaults to 0 (round up to an integer). x = x * (10 ^ decimalPlaces) x = (x + 0.5 - (x + 0.5) % 1) / (10 ^ decimalPlaces) return x end
This function is very useful when calculating Win/Lose ratio (or for me, chance of winning in "%") and game progress (Like when you have completed the game "100%" which is kind of rare to use).
Even though it might seem useless, I still hope people will learn some math in it.
Try typing for example
round(math.pi, 2) or
round(1.79) under the function in your script to try it out!