math
v0.0.6randomSeed(seed);Set a random seed
Arguments
seedThe seed valueReturns
numberThe random valuerandom(min, max);Get a random number
Arguments
minThe minimum of the rangemaxThe maximum of the rangeReturns
numberThe random value random() -- random number between 0 and 1
random(3) -- random number between 0 and 3
random(3, 12) -- random number between 3 and 12
random({ 'A', 'B', 'C' }) -- random element in tableround(x);Round a number to the nearest integer
Arguments
xThe value to roundReturns
intThe rounded valuefloor(x);floor is a function that takes in a number, and returns the greatest integer less or equal to x
see here
Arguments
xThe value to floorReturns
intgreatest integer less than or equals to xceil(x);ceil is a function that takes in a number, and returns the smallest integer greater or equal to x
see here
Arguments
xThe value to floorReturns
intThe floored valuemin(a, b);Return the smallest value.
Can also take any number of arguments, or a table.
Arguments
aThe first valuebThe second valueReturns
numberThe smallest value min(6, 7); -- returns 6
min(6, 7, 4); -- returns 4
min({ 6, 7, 4 }); -- returns 4max(a, b);Return the largest value.
Can also take any number of arguments, or a table.
Arguments
aThe first valuebThe second valueReturns
numberThe largest value max(2, 5); -- returns 5
max(2, 5, 7); -- returns 7
max({ 2, 5, 7 }); -- returns 7abs(x);Returns the absolute value of x which is its distance from 0
see here
Arguments
xThe input valueReturns
numberThe absolote value of the inputmap(x, s1, e1, s2, e2);Maps x from an original range to a target range
Arguments
xThe value to maps1The start of the initial rangee1The end of the initial ranges2The start of the target rangee2The end of the target rangeReturns
numberThe mapped valuedist(x1, y1, x2, y1);Calculates the distance between 2 points in 2D space
Arguments
x1The x coordinate of the first pointy1The y coordinate of the first pointx2The x coordinate of the second pointy1The y coordinate of the second pointReturns
numberThe distance between the pointsconstrain(x, min, max);Limits x to a minimum and maximum value
Arguments
xThe input valueminThe minimum valuemaxThe maximum valueReturns
numberThe constrained valuesin(x);Sine function (Trigonometry)
Arguments
xThe input valueReturns
numberThe output valuecos(x);Cosine function (Trigonometry)
Arguments
xThe input valueReturns
numberThe output valuetan(x);Tangent function (Trigonometry)
Arguments
xThe input valueReturns
numberThe output valuePIGlobalNo description
TWO_PIGlobalNo description
HALF_PIGlobalNo description
QUARTER_PIGlobalNo description