utils.lua 194 B

1234
  1. function math.clamp(val, lower, upper)
  2. if lower > upper then lower, upper = upper, lower end -- swap if boundaries supplied the wrong way
  3. return math.max(lower, math.min(upper, val))
  4. end