Repository navigation
Library: Math
Aviril edited this page Nov 29, 2024
·
21 revisions
Lua provides built in math module by default, however it lacks certain special vendors & classes that are essentially required for most of the generic cases such as Quat, Matrix etc; thus, the extension!
It gets imported automatically by default whenever you initialize assetify.
--Declare it globally only once
loadstring(exports.assetify_library:import())()Our extensions are written with backwards compatibility in mind; Expect your previous code to work as usual! However we recommend upgrading to newer syntax.
local float: result = math.round(
float: value,
int: decimals --(Optional) By default its 0 if left unspecified
)local float: result = math.percent(
float: value,
float: percent
)local float: result = math.findDistance2D(
float: x1,
float: y1,
float: x2,
float: y2
)local float: result = math.findDistance3D(
float: x1,
float: y1,
float: z1
float: x2,
float: y2,
float: z2
)local float: result = math.findRotation2D(
float: x1,
float: y1,
float: x2,
float: y2
)@Objective: Generates new coords of an existing 2D-Point after rotating it by specified distance & rotation angle.
local float: result = math.findPointByRotation2D(
float: x,
float: y,
float: distance,
float: rotation
)