[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How catch new globals?
- From: Javier Guerra <javier@...>
- Date: Mon, 31 Oct 2005 11:43:27 -0500
Quoting "J. Perkins" <starkos@gmail.com>:
> For 5.0 I tried to do this:
>
> lua_pushvalue(L, LUA_GLOBALSINDEX);
> lua_getmetatable(L, -1);
> lua_pushstring(L, "__newindex");
> lua_pushcfunction(L, getglobal);
> lua_settable(L, -3)
are you checking what's returned by lua_getmetatable()? you're supposed to
create a table, populate it and then assign (with setmetatable()) to a value.
if not, getmetatable() will return nil (because that value doesn't have a
metatable yet)
------
Javier