class MathUtil
package fivem.shared.util
Small numeric helpers that the Haxe standard library doesn't ship and that
game code reaches for constantly. Everything is inline, so calls vanish
into the generated Lua.
Static variables
Static methods
staticinlinedeltaDegrees(from:Float, to:Float):Float
The signed shortest rotation from from to to, in (-180, 180].
Use this instead of plain subtraction so turning from 350° to 10° gives
20, not -340.
staticinlineinverseLerp(from:Float, to:Float, value:Float):Float
The inverse of lerp: where value sits between from and to, as 0..1.
staticinlinelerp(from:Float, to:Float, t:Float):Float
Linear interpolation. t is not clamped — pass values outside 0..1 to extrapolate.
staticinlinemap(value:Float, fromMin:Float, fromMax:Float, toMin:Float, toMax:Float):Float
Remaps value from one range onto another.
staticinlinerandom():Float
A random float in [0, 1).
Calls Lua's math.random directly instead of Haxe's Math.random.
Haxe's version makes the generated file seed the RNG at load time with
_G.math.randomseed(_G.os.time());
and FiveM's client sandbox does not expose os at all, so that line
takes the resource down before a line of your code runs:
SCRIPT ERROR: attempt to index a nil value (field 'os')
Lua 5.4 seeds itself at startup, so nothing is lost by skipping it.
staticinlinesmoothStep(edge0:Float, edge1:Float, value:Float):Float
Smoothstep easing between two edges — a gentler alternative to lerp for camera and UI motion.