utils: add a simple function to substract a variable to another to zero
This commit is contained in:
parent
ea5011642c
commit
dcfa657f64
1 changed files with 10 additions and 0 deletions
|
@ -40,6 +40,16 @@ function Math.round(num)
|
|||
return math.floor(num + 0.5)
|
||||
end
|
||||
|
||||
function Math.toZero(num, sub)
|
||||
local sub = math.floor(sub)
|
||||
|
||||
if math.abs(num) < sub then
|
||||
return 0
|
||||
else
|
||||
return num - (sub * Math.sign(num))
|
||||
end
|
||||
end
|
||||
|
||||
-- VECTOR/DIRECTION functions
|
||||
-- Easy-to-use function to handle point and motion
|
||||
|
||||
|
|
Loading…
Reference in a new issue