From 8e2e6ae15c37644e803a3f12865c6e96bb6ec983 Mon Sep 17 00:00:00 2001 From: Chris Gregan Date: Thu, 5 May 2016 17:59:56 +0100 Subject: [PATCH] Added Round function to fungus module --- .../Thirdparty/FungusLua/Resources/Lua/fungus.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Assets/Fungus/Thirdparty/FungusLua/Resources/Lua/fungus.txt b/Assets/Fungus/Thirdparty/FungusLua/Resources/Lua/fungus.txt index 0a665fe4..036fcda4 100644 --- a/Assets/Fungus/Thirdparty/FungusLua/Resources/Lua/fungus.txt +++ b/Assets/Fungus/Thirdparty/FungusLua/Resources/Lua/fungus.txt @@ -12,6 +12,20 @@ function M.inspect(v) print (inspect.inspect(v)) end +------------ +-- Math +------------ + +-- rounds a number to the nearest decimal places +-- e.g. round(1.523, 100) -- 1.52 +function round(val, decimal) + if (decimal) then + return math.floor( (val * 10^decimal) + 0.5) / (10^decimal) + else + return math.floor(val+0.5) + end +end + ------------- -- Coroutines -------------