lua-users home
lua-l archive

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

Quoting "J. Perkins" <>: 
> 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)