aboutsummaryrefslogtreecommitdiff
path: root/builtin/common/misc_helpers.lua
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2021-05-13 18:06:47 +0200
committerElias Fleckenstein <eliasfleckenstein@web.de>2021-05-13 18:06:47 +0200
commitf3e741dad1311e0b4057b530386e246f921be52c (patch)
tree64581e3f0ddfa9d4740eed7b545fe3db87b8c126 /builtin/common/misc_helpers.lua
parent96a37aed31cfb9c131e46eda80bdbe3d2289a546 (diff)
parent69c70dd319532f7860f211f4a527a902b0386e49 (diff)
downloaddragonfireclient-f3e741dad1311e0b4057b530386e246f921be52c.tar.xz
Merge branch 'master' of https://github.com/minetest/minetest
Diffstat (limited to 'builtin/common/misc_helpers.lua')
-rw-r--r--builtin/common/misc_helpers.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua
index 308e2c7c7..324d83b07 100644
--- a/builtin/common/misc_helpers.lua
+++ b/builtin/common/misc_helpers.lua
@@ -244,6 +244,15 @@ function math.factorial(x)
return v
end
+
+function math.round(x)
+ if x >= 0 then
+ return math.floor(x + 0.5)
+ end
+ return math.ceil(x - 0.5)
+end
+
+
function core.formspec_escape(text)
if text ~= nil then
text = string.gsub(text,"\\","\\\\")