diff options
author | SmallJoker <mk939@ymail.com> | 2014-12-05 23:18:52 +0100 |
---|---|---|
committer | Kahrl <kahrl@gmx.net> | 2014-12-06 10:07:25 +0100 |
commit | 2fd14e1bd53918b3c4fcdfbc81294ff8b7afe1fa (patch) | |
tree | 7a997950d75f1d2a1c49b30128b8535d3a25af45 /builtin/common/misc_helpers.lua | |
parent | 0e78aa296ee8b552273fdc9d6fabec0fb01d2e4a (diff) | |
download | minetest-2fd14e1bd53918b3c4fcdfbc81294ff8b7afe1fa.tar.gz minetest-2fd14e1bd53918b3c4fcdfbc81294ff8b7afe1fa.tar.bz2 minetest-2fd14e1bd53918b3c4fcdfbc81294ff8b7afe1fa.zip |
Add Lua helper functions vector.apply(v) math.sign(x, tolerance)
Diffstat (limited to 'builtin/common/misc_helpers.lua')
-rw-r--r-- | builtin/common/misc_helpers.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index 0b608126e..e1dc28965 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -213,6 +213,17 @@ function math.hypot(x, y) end -------------------------------------------------------------------------------- +function math.sign(x, tolerance) + tolerance = tolerance or 0 + if x > tolerance then + return 1 + elseif x < -tolerance then + return -1 + end + return 0 +end + +-------------------------------------------------------------------------------- function get_last_folder(text,count) local parts = text:split(DIR_DELIM) |