Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- This is some of math functions that available in GLua but missing in vanilla Lua.
- math.Clamp = math.Clamp or function(val, lower, upper)
- assert(val and lower and upper, "not very useful error message here")
- if lower > upper then lower, upper = upper, lower end -- swap if boundaries supplied the wrong way
- return math.max(lower, math.min(upper, val))
- end
- math.Round = math.Round or function(num, numDecimalPlaces)
- local mult = 10^(numDecimalPlaces or 0)
- return math.floor(num * mult + 0.5) / mult
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement