lua-users home
lua-l archive

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


I am trying to get the value in a table passed to 'C' from lua.

[LUA]
names={car="red", house="brick"}
doit(names)

[C]
static int doit(lua_State *L)
{
char *text;

lua_pushstring(L, "house");
lua_gettable(L, 2)  //because the table is at 2 in the stack right?
text=(char *)lua_tostring(L, 1);

}


but for some strange reason, text is NULL. I am assuming that the table names was passed on the stack as index 1 and then I pushed a string on the stack, so the table is now index 2, right?? but the string "brick" does not get pushed onto the stack.

I tried to lua_getglobal before the pushstring to try to get the table, but I dont know how to getglobal the table that is being sent by lua.

any thoughts?

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp