Skip to content

Math

Inherits: LibTSMModule

Functions

Bound

lua
function Lua.Math.Bound(value, minValue, maxValue)
  -> number

Bounds a number between a min and max value.

Parameters:

NameTypeDescription
valuenumberThe number to be bounded
minValuenumberThe min value
maxValuenumberThe max value

Returns:

TypeDescription
number

Ceil

lua
function Lua.Math.Ceil(value, sig)
  -> number

Rounds a value up to a specified significant value.

Parameters:

NameTypeDescription
valuenumberThe number to be rounded
signumberThe value to round up to the nearest multiple of (defaults to 1)

Returns:

TypeDescription
number

Floor

lua
function Lua.Math.Floor(value, sig)
  -> number

Rounds a value down to a specified significant value.

Parameters:

NameTypeDescription
valuenumberThe number to be rounded
signumberThe value to round down to the nearest multiple of (defaults to 1)

Returns:

TypeDescription
number

GetNan

lua
function Lua.Math.GetNan()
  -> number

Returns NAN.

Returns:

TypeDescription
number

IsNan

lua
function Lua.Math.IsNan(value)
  -> boolean

Checks if a value is NAN.

Parameters:

NameTypeDescription
valuenumberThe number to check

Returns:

TypeDescription
boolean

Round

lua
function Lua.Math.Round(value, sig)
  -> number

Rounds a value to a specified significant value.

Parameters:

NameTypeDescription
valuenumberThe number to be rounded
signumberThe value to round to the nearest multiple of (defaults to 1)

Returns:

TypeDescription
number

Scale

lua
function Lua.Math.Scale(value, fromStart, fromEnd, toStart, toEnd)
  -> number

Scales a value from one range to another.

Parameters:

NameTypeDescription
valuenumberThe number to be scaled
fromStartnumberThe start value of the range to scale from
fromEndnumberThe end value of the range to scale from (can be less than fromStart)
toStartnumberThe start value of the range to scale to
toEndnumberThe end value of the range to scale to (can be less than toStart)

Returns:

TypeDescription
number