From 876d30671d24b92cc343043c5e676f25cebbad82 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Fri, 4 Dec 2020 11:59:32 +0100 Subject: [PATCH] feat(math): add a basic wrap and limit function --- birb/utils/math.lua | 9 +++++++++ 1 file changed, 9 insertions(+) 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