lua-users home
lua-l archive

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


On Mon, 23 Feb 2004 20:56:02 -0700, Michael Newberry wrote:
> I'm sorry, but I guess I just don't understand the stack
> manipulation here. For one thing, lua_rawget() returns void, so how
> does that get me the value of the array element?

The rawget doesn't return a value, it places that value at the top of 
the stack.  To actually retrieve a value you'd have to call 
lua_tonumber() or whatever is appropriate for your data.

> In addition, the parent class that I called "T" is subject to
> different names as new classes are derived from T, so
> lua_getglobal() is out. I assume I would get the class name from
> the stack using something like lua_gettable( L, 1 ) ?

Well, the C code has to know what it's looking for, right?  If you're 
trying to access a global, then you use lua_getglobal() with the 
appropriate name.  If the C function is _passed_ a table (i.e. it was 
called from Lua), then that's a different thing altogether and you'll 
want to grab the table straight off the stack.

I was under the impression that your C function was simply trying to 
get something out of the lua state and wasn't a callback.

Brian