utils/math: add a function to return a value somewhere between two numbers

This commit is contained in:
Kazhnuz 2019-05-02 16:18:12 +02:00
parent c1cefa9f92
commit 8073951822

View file

@ -50,6 +50,12 @@ function Math.toZero(num, sub)
end end
end end
function Math.between(num, value1, value2)
local min = math.min(value1, value2)
local max = math.max(value1, value2)
return math.min(math.max(num, min), max)
end
-- VECTOR/DIRECTION functions -- VECTOR/DIRECTION functions
-- Easy-to-use function to handle point and motion -- Easy-to-use function to handle point and motion