diff --git a/gamecore/utils/math.lua b/gamecore/utils/math.lua index 1c29373..fea382b 100644 --- a/gamecore/utils/math.lua +++ b/gamecore/utils/math.lua @@ -50,6 +50,12 @@ function Math.toZero(num, sub) end end +function Math.between(num, value1, value2) + local min = math.min(value1, value2) + local max = math.max(value1, value2) + return math.min(math.max(num, min), max) +end + -- VECTOR/DIRECTION functions -- Easy-to-use function to handle point and motion