lia.math

Various useful mathematical functions.

Functions

ApproachAngleSpeed(start, dest, speed)

Approaches an angle towards a target angle at a specified speed.

Parameters

  • start Angle

    The starting angle.

  • dest Angle

    The target angle.

  • speed Integer

    The speed at which to approach the target.

Returns

  • any

    Angle The approached angle.

ApproachSpeed(start, dest, speed)

Approaches a value towards a target value at a specified speed.

Parameters

  • start Angle

    The starting value.

  • dest Angle

    The target value.

  • speed Integer

    The speed at which to approach the target.

Returns

  • any

    The approached value.

ApproachVectorSpeed(start, dest, speed)

Approaches a vector towards a target vector at a specified speed.

Parameters

  • start Angle

    Vector The starting vector.

  • dest Angle

    Vector The target vector.

  • speed Integer

    The speed at which to approach the target.

Returns

  • any

    Vector The approached vector.

Bias(x, amount)

Applies a bias to a value based on an amount.

Parameters

  • x Integer

    The value to bias.

  • amount Integer

    The bias amount.

Returns

  • any

    The biased value.

ClampAngle(val, min, max)

Clamps an angle to a specified range.

Parameters

  • val Integer

    The angle to clamp.

  • min Integer

    The minimum angle of the range.

  • max Integer

    The maximum angle of the range.

Returns

  • any

    Angle The clamped angle.

ClampedRemap(val, frommin, frommax, tomin, tomax)

Remaps a value from one range to another and clamps it.

Parameters

  • val Integer

    The value to remap.

  • frommin Integer

    The minimum value of the original range.

  • frommax Integer

    The maximum value of the original range.

  • tomin Integer

    The minimum value of the target range.

  • tomax Integer

    The maximum value of the target range.

Returns

  • any

    The remapped and clamped value.

Gain(x, amount)

Applies a gain to a value based on an amount.

Parameters

  • x Integer

    The value to apply gain to.

  • amount Integer

    The gain amount.

Returns

  • any

    The value with applied gain.

InRange(val, min, max)

Checks if a value is within a specified range.

Parameters

  • val Integer

    The value to check.

  • min Integer

    The minimum value of the range.

  • max Integer

    The maximum value of the range.

Returns

  • any

    boolean True if the value is within the range, false otherwise.

UnitsToCentimeters(units)

Converts units to centimeters.

Parameters

  • units number

    The units to convert

Returns

  • any

    number The equivalent measurement in centimeters

UnitsToInches(units)

Converts units to inches.

Parameters

  • units number

    The units to convert

Returns

  • any

    number The equivalent measurement in inches

UnitsToMeters(units)

Converts units to meters.

Parameters

  • units number

    The units to convert

Returns

  • any

    number The equivalent measurement in meters

chance(chance)

Rolls a chance based on a given probability.

Parameters

  • chance Integer

    The probability of success in percentage

Returns

  • bool

    True if the chance is successful, false otherwise