feat(math): add a basic wrap and limit function

This commit is contained in:
Kazhnuz Klappsthul 2020-12-04 11:59:32 +01:00
parent 12b4b3fbc1
commit 876d30671d
1 changed files with 9 additions and 0 deletions

View File

@ -56,6 +56,15 @@ function Math.between(num, value1, value2)
return math.min(math.max(num, min), max)
end
function Math.wrapAndLimit(num, min, max)
if (num < min) then
num = max
elseif (num > max) then
num = min
end
return num
end
-- VECTOR/DIRECTION functions
-- Easy-to-use function to handle point and motion