Working with Lua arrays
Yes – a Lua table with only integer keys is called an array or a sequence. In script.lua
, add the following array:
seq = { 0, 0, 0 }
From the C++ side, compared with string keys, the only difference is the data type of the keys. It’s straightforward to overload the getTable
and setTable
functions by using integer keys. In LuaExecutor.h
, add the following declarations:
class LuaExecutor { public: LuaValue getTable(const std::string &table, int index); void setTable(const std::string &table, int index, const LuaValue &value); };
index...