feat: add wrap function

This commit is contained in:
Kazhnuz 2022-01-02 17:11:52 +01:00
parent a677902f6c
commit 47b86c1862

View file

@ -64,6 +64,18 @@ function Math.either(bool, val1, val2)
end
end
function Math.wrap(val, min, max)
while (val < min) do
local diff = ((min-1) - val)
val = max - diff
end
while (val > max) do
local diff = ((max+1) - val)
val = min + diff
end
return val
end
-- VECTOR/DIRECTION functions
-- Easy-to-use function to handle point and motion