Neatro's Satellite Lua Documentation
This is a collection of additional builtin libraries that used to be included in an older project of mine, now here!
Copyright (c) 2024 Neatro
redistribution is not permitted.
Jump to: Builtins Additional Vectors Angles Matrices Colors
For additional lua help: Lua 5.3 Reference Manual
Builtins
Additional math
math.randomf( min, max )
number
Generate a random floating point number between 0 and 1.
math.interpolate( startpoint, endpoint, fraction )
any
Interpolates startpoint and endpoint, based on fraction. fraction can also be below 0 or above 1 to extrapolate.
math.clamp( value, min, max )
number
Clamps value between min and max.
Additional table
table.count( table )
number
Counts all values in a table, including string keys. this function is slow than using #, but will count every key.
table.empty( table )
Remove all values from a table.
Hooks
hook.Add( event, index, callback )
Adds a callback to an event using index, this hook is triggerable by running hook.Run or hook.RunAll.
Additional functions
Utility
PrintTable( tbl )
Print a table recursively, colorfully. Mainly used for debugging table data.
PrintTableFast( tbl )
Print a table recursively, without added color. Faster than PrintTable. Mainly used for debugging table data.
Vectors
Class
Vector( x, y, z )
Vector
XYZ spatial Vector object.
Methods
Vector:GetNormalized()
Vector
Returns a new vector with magnitude of 1 of the orignal vector.
Vector:GetLength()
number
Calculate magnitude of Vector.
Vector:GetLength2()
number
Calculate magnitude of Vector squared. This function is generally faster as it doesn't do a square root.
Vector:GetLength2D()
number
Calculate magnitude of Vector, only using it's x and y components.
Vector:GetLength2D2()
number
Calculate magnitude of Vector squared, only using it's x and y components. This function is generally faster as it doesn't do a square root.
Vector:Round()
Vector
Returns a new vector with it's components rounded to closest integer.
Vector:Floor()
Vector
Returns a new vector with it's components rounded down.
Vector:Ceil()
Vector
Returns a new vector with it's components rounded up.
Vector:Cross( vector )
Vector
Returns a new vector which is a cross product of itself with the argument vector
Vector:GetDistance( vector )
number
Returns number which is the distance of itself with the argument vector
Vector:GetDistance2( vector )
number
Returns number which is the distance of itself squared with the argument vector. This function is generally faster as it doesn't do a square root.
Vector:Dot( vector )
number
Returns number which is the dot product of itself with the argument vector
Vector:RotateAroundAxis( vector, degrees, radians )
Vector
Returns a new vector which rotated around the argumentative vector by degrees or radians. (second argument can be nil for radians!)
Vector:Clone()
Vector
Returns a new vector of itself, this is a unique object.
Vector:GetColor()
Color
Returns the vector turned into an RGBA Color object.
Vector:GetAngle()
Angle
Calculate Euler angles from Vector.
Vector:Rotate( angle )
Vector
Returns a new vector rotated by the argument Euler Angles.
Angles
Class
Angle( pitch, yaw, roll )
Angle
PYR Euler Angle object.
Methods
Angle:ToVector()
Vector
Returns a new vector pointing in the direction of the Euler angle. This ignores the roll component.
Matrices
Class
Matrix( ... )
Matrix
4x4 Matrix object. Creates an identity matrix when no arguments are given.
Methods
Matrix:Translate( Vector )
Modifies the matrix itself. Translates the matrix by the given vector.
Matrix:Scale( Vector )
Modifies the matrix itself. Scales the matrix by the given vector.
Matrix:Rotate( Angle )
Modifies the matrix itself. Rotates the matrix by the given Euler angle.
Matrix:GetTranslation()
Vector
Translation of the matrix
Matrix:GetScale()
Vector
Scale of the matrix
Matrix:GetRotation()
Angle
Rotation of the matrix
Matrix:SetTranslation( Vector )
Modifies the matrix itself. Sets the translation of the matrix by the given vector.
Matrix:SetScaling( Vector )
Modifies the matrix itself. Sets the scale of the matrix by the given vector.
Matrix:SetRotation( Angle )
Modifies the matrix itself. Sets the rotation of the matrix by the given Euler angle.
Matrix:GetColumnVector( column )
Vector
Gets the first three fields of the argument column ( 1, 2, 3 or 4 ) of the matrix as a Vector.
Matrix:SetColumnVector( column, Vector )
Vector
Sets the first three fields of the argument column ( 1, 2, 3 or 4 ) of the matrix using the argument Vector.
Matrix:Apply( Matrix2 )
Modifies the matrix itself. Applies the values of Matrix2 to the Matrix, copying it.
Library
matrix.Identity( ... )
Matrix
Creates a new matrix based on the arguments, defaults to an identity matrix.
matrix.FromVector( Vector )
Matrix
Creates a new matrix based on the vector as translation of the identiy matrix.
matrix.FromScale( Vector )
Matrix
Creates a new matrix based on the vector as scale of the identiy matrix.
matrix.FromAngle( Angle )
Matrix
Creates a new matrix based on the Euler angle as rotation of the identiy matrix.
Colors
Class
Color( r, g, b, a )
Color
RGBA color object, the alpha argument is optional and defaults to 255. Supports floats and values beyond 0 and 255 too, but is not advised.