-
Notifications
You must be signed in to change notification settings - Fork 1
`Lua Addons: Math
GhostglowDev edited this page Mar 21, 2024
·
2 revisions
local math = require "ghostutil.lua-addons.math"
-
epsilon
=0.0000001
-
max_int
=0x7FFFFFFF
-
min_int
=-0x7FFFFFFF
-
max_float
=1.79e+308
-
min_float
=0.0000000001
-
imaginary
=i
-
infinity
=inf
-
negative_infinity
=-inf
-
a
: From -
b
: Target -
ratio
: Ratio, duh. (From 0 to 1)
function onUpdate(elapsed)
-- Example is currently unavailable
end
Bound a number by a minimum and maximum. Ensures that this number is no smaller than the minimum, and no larger than the maximum
-
value
: Value -
max
: Maximum -
min
: Minimum
debugPrint(math.boundto(10, 7, 1))
-- prints 7
-
n
: To invert
math.invert(-1)
-- returns 1 (Basically like absolute)
math.invert(1)
-- returns -1
Checks if x
is negative or positive (If x
equals 0 then it will return false because 0 is not positive nor negative)
-
x
: To check
math.ispositive(1)
-- returns true
math.isnegative(1)
-- returns false
math.ispositive(0)
-- returns false
-
n
: To be factored
math.fact(4)
-- returns 24
math.fact(0)
-- returns 1
-
value
: Value -
decimals
: Total decimals you want in the new value
local accuracy = rating*100
accuracy = math.floordecimal(accuracy, 2);
-- if the accuracy is for example, 79.11293283
-- it now shows 79.11
-
value
: Value
math.round(5.5)
-- returns 6
math.round(5.23)
-- returns 5
It's so self-explainatory that I won't explain it
local x = 10
local x2 = 0
local x3 = math.getmidpoint(x, x2)
-- x3 returns 5
Reading this wiki is recommended before using GhostUtil