class LuaTables
package fivem.shared.util
Conversions between raw Lua tables and Haxe collections.
This is needed more often than it looks. Haxe arrays on the Lua target are
0-based objects carrying their own length field, while everything coming
out of FiveM — GetActivePlayers(), GetGamePool(),
GetEntitiesInRadius(), command arguments, msgpack-decoded event payloads
— is a plain 1-based Lua table. Assigning one to an Array<T> type-checks
but produces an array that reads as empty.
Anything in this library that returns a collection has already been through these helpers; they're exposed for when you call a native directly.
Static methods
staticinlinefromArray<T>(values:Array<T>):Table<Int, T>
Converts a Haxe Array into a 1-based Lua table, for passing back into natives.
statictoArray<T>(raw:Dynamic):Array<T>
Converts a 1-based Lua array table into a Haxe Array. A null input
becomes an empty array, which is what natives return for "no results".
staticinlinetoObject(raw:Dynamic):Dynamic
Converts a string-keyed Lua table into an anonymous structure, so its fields can be read with ordinary dot access.