feat: add wrap function
This commit is contained in:
parent
a677902f6c
commit
47b86c1862
1 changed files with 12 additions and 0 deletions
|
@ -64,6 +64,18 @@ function Math.either(bool, val1, val2)
|
||||||
end
|
end
|
||||||
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
|
-- VECTOR/DIRECTION functions
|
||||||
-- Easy-to-use function to handle point and motion
|
-- Easy-to-use function to handle point and motion
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue