Class LuaTable

All Implemented Interfaces:
com.esotericsoftware.kryo.KryoSerializable
Direct Known Subclasses:
Globals, ScriptManager.ReadOnlyLuaTable

public class LuaTable extends LuaValue implements com.esotericsoftware.kryo.KryoSerializable
Subclass of LuaValue for representing lua tables.

Almost all API's implemented in LuaTable are defined and documented in LuaValue.

If a table is needed, the one of the type-checking functions can be used such as istable(), checktable(), or opttable(LuaTable)

The main table operations are defined on LuaValue for getting and setting values with and without metatag processing:

To iterate over key-value pairs from Java, use

 
 LuaValue k = LuaValue.NIL;
 while ( true ) {
    Varargs n = table.next(k);
    if ( (k = n.arg1()).isnil() )
       break;
    LuaValue v = n.arg(2)
    process( k, v )
 }

As with other types, LuaTable instances should be constructed via one of the table constructor methods on LuaValue:

See Also:
  • Field Details

  • Constructor Details

    • LuaTable

      public LuaTable()
      Construct empty table
    • LuaTable

      public LuaTable(int narray, int nhash)
      Construct table with preset capacity.
      Parameters:
      narray - capacity of array part
      nhash - capacity of hash part
    • LuaTable

      public LuaTable(LuaValue[] named, LuaValue[] unnamed, Varargs lastarg)
      Construct table with named and unnamed parts.
      Parameters:
      named - Named elements in order key-a, value-a, key-b, value-b, ...
      unnamed - Unnamed elements in order value-1, value-2, ...
      lastarg - Additional unnamed values beyond unnamed.length
    • LuaTable

      public LuaTable(Varargs varargs)
      Construct table of unnamed elements.
      Parameters:
      varargs - Unnamed elements in order value-1, value-2, ...
    • LuaTable

      public LuaTable(Varargs varargs, int firstarg)
      Construct table of unnamed elements.
      Parameters:
      varargs - Unnamed elements in order value-1, value-2, ...
      firstarg - the index in varargs of the first argument to include in the table
  • Method Details