math library
Extensions of the math library: snake_case aliases for the built-in functions, scaling of
sizes to the screen resolution and checks for even, odd and divisible numbers.
Numbers get the math library as their methods here, so that n:floor() and
n:clamp(0, 3) work. The Time and Unit classes add their constructors and converters
to the library as well, as in math.minutes(5) and math.meters(2). This file also defines
the util functions for hexadecimal numbers and 2D geometry.
Summary
Functions
Functions
Checks whether a number is divisible by another number without a remainder.
Parameters
- num Number
- factor Number divisor
Returns
- Boolean
Checks whether a number is even.
Parameters
- num Number
Returns
- Boolean
Checks whether a number is odd.
Parameters
- num Number
Returns
- Boolean
Scales a size that was designed for a 1080 pixels tall screen to the current screen height. Clientside only, since it depends on the screen resolution.
Parameters
- size Number size at 1080p
Returns
- Number scaled size, rounded down
Scales a width and a height that were designed for a 1920x1080 screen to the current screen resolution. Clientside only.
Parameters
- x Number width at 1920x1080
- y Number height at 1920x1080
Returns
- Number scaled width
- Number scaled height
Scales a size that was designed for a 1920 pixels wide screen to the current screen width. Clientside only, since it depends on the screen resolution.
Parameters
- size Number size at 1920 pixels of width
Returns
- Number scaled size, rounded down