lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



.subtable[1].field is of course what I meant.. :)


30.11.2004 kello 17:42, Asko Kauppi kirjoitti:


You may also want to have a look at LuaX sources (Sources/gluax.c: _glua_totable()). Do keep in mind that numbers and strings are different in Lua, as indices. I deal with this by making "subtable.1.field" match .subtable.1.field (that is, 1 and not "1"). Confusing? Sorry..

-ak

30.11.2004 kello 15:20, E. Wing kirjoitti:

Thank you! The code is very much appreciated! This is exactly what I needed.

-Eric

From: Malte Thiesen <malte.thiesen@kamalook.de>
Hi,
I use the following code to create nested tables. The function takes a
Lua-state and a string like "very.deeply.nested" and then creates all
the subtables down to "nested" and leaves the "deepest" table on the stack. It also makes sure that the tables aren't overwritten, so if you create "very.deeply.nested" and "very.deeply" already exists only "nested" is created. Unlike you I use std::string not C-strings so you may have to
adapt the code a little.

bool CreateNestedTable(lua_State * L, const std::string & TableName)
{