lua-users home
lua-l archive

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


The following works OK /for what I am doing/
L1 is the thread state.

   lua_newtable(L1); /* the env, */
   lua_createtable(L1,0,1); /* the meta table */
   lua_pushvalue(L1,LUA_GLOBALSINDEX);
   lua_setfield(L1,-2, "__index");
   lua_setmetatable(L1, -2); /* setmetatable(env, {_index = _G }) */
   lua_pushvalue(L1,-1);
   lua_replace(L1, LUA_GLOBALSINDEX);