1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-12 16:15:20 +02:00

Add Lua helper functions vector.apply(v) math.sign(x, tolerance)

This commit is contained in:
SmallJoker
2014-12-05 23:18:52 +01:00
committed by Kahrl
parent 0e78aa296e
commit 2fd14e1bd5
3 changed files with 23 additions and 0 deletions

View File

@@ -212,6 +212,17 @@ function math.hypot(x, y)
return x * math.sqrt(1 + t * t)
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)