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

staticinlinecount(raw:Dynamic):Int

The number of entries in the array portion of a Lua table.

staticinlinefromArray<T>(values:Array<T>):Table<Int, T>

Converts a Haxe Array into a 1-based Lua table, for passing back into natives.

staticinlinefromMap<T>(values:Map<String, T>):Table<String, T>

Converts a Haxe Map into a Lua table.

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".

statictoMap<T>(raw:Dynamic):Map<String, T>

Converts a string-keyed Lua table into a Haxe Map.

staticinlinetoObject(raw:Dynamic):Dynamic

Converts a string-keyed Lua table into an anonymous structure, so its fields can be read with ordinary dot access.