lua-users home
lua-l archive

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


On Thu, Nov 12, 2009 at 5:00 PM, zweifel <zweifel@gmail.com> wrote:
> Why cant I pass a table inside a table with the following code:
>
>        //first table
>         lua_newtable(lua_state);
>
>        //second table inside the first table
>        lua_newtable(lua_state);
>
>         lua_pushstring(lua_state, "x");         //key
>         lua_pushnumber(lua_state, (double)array[0]);            //value
>         lua_settable(lua_state, -3);
>
>         lua_pushstring(lua_state, "y");         //key
>         lua_pushnumber(lua_state, (double)array[1]);            //value
>         lua_settable(lua_state, -3);
>
>         lua_pushstring(lua_state, "z");         //key
>         lua_pushnumber(lua_state, (double)array[2]);            //value
>         lua_settable(lua_state, -3);
>
>         //finish the second table and set it as index to the first table
>         lua_rawseti(lua_state, -2, index);
>
>         //set name of the first table
>         lua_setglobal(lua_state, lua_table_name);


This code looks fine to me. You must be doing something else wrong?

-- 
-Patrick Donnelly

"Let all men know thee, but no man know thee thoroughly: Men freely
ford that see the shallows."

- Benjamin Franklin