diff --git a/birb/utils/math.lua b/birb/utils/math.lua index b71c5d3..3120360 100644 --- a/birb/utils/math.lua +++ b/birb/utils/math.lua @@ -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