Lazily evaluated table. For performance reasons, we sometimes return a custom table-like type instead of a native Lua table. This custom type lazily constructs the necessary Lua wrappers of the corresponding C++ objects, therefore preventing their unnecessary construction in some cases.
There are some notable consequences to the usage of a custom table type rather than the native Lua table type:
Iterating a custom table is only possible using the
pairs Lua function;
ipairs won't work. Another key
difference is that custom tables cannot be serialised into a game save file -- if saving the game would require
serialisation of a custom table, an error will be displayed and the game will not be saved.
for _, p in pairs(game.players) do game.player.print(p.name); end
ipairsis not supported with custom tables.
for _, p in ipairs(game.players) do game.player.print(p.name); end -- incorrect; use pairs instead
global.pwill be useable as one might expect. However, as soon as the user tries to save the game, a "LuaCustomTable cannot be serialized" error will be shown. The game will remain unsaveable so long as
global.prefers to an instance of a custom table.
global.p = game.players -- This has high potential to make the game unsaveable
|operator  :: Any [RW]||Access an element of this custom table.|
|operator # :: uint [R]||Number of elements in this table.|
|valid :: boolean [R]||Is this object valid?|
|object_name :: string [R]||The class name of this object.|
|help() → string||All methods and properties that this object supports.|