[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: Lua Tables from 'C'
- From: "Peter Prade" <prade@...>
- Date: Mon, 15 Oct 2001 03:03:57 +0200
try lua_gettable(L, -2)
the table is not #2 on the stack, but the second from the top!
(positive numbers indicate absolute position from the bottom of the stack,
negative a position relative to the top)
see also Chapter "5.2 - The Stack and Indices" in the manual:
[mailto:email@example.com]On Behalf Of Denis Lamarche
Sent: Monday, October 15, 2001 2:15 AM
To: Multiple recipients of list
Subject: Lua Tables from 'C'
I am trying to get the value in a table passed to 'C' from lua.
static int doit(lua_State *L)
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.
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp