[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to load buffer from C to the particular Lua namespace(table)
- From: "Dmitriy Iassenev" <iassenev@...>
- Date: Thu, 25 Sep 2003 10:51:18 +0300
hi,
I changed my code and now string and math loaded before lua_newtable(...),
but it changed nothing, I get the following error message
"attempt to index global 'string' (a nil value)", i.e. module string is
invisible inside the module "extension.lua". What am I doing wrong?
Best regards,
Dmitriy Iassenev
> Hey watch your stack!
>
> -------------------------------------
> lua_newtable(luaVM);
>
> luaopen_string (luaVM);
> luaopen_math (luaVM);
>
> lua_pushstring(luaVM, "core");
> lua_pushvalue(luaVM, -2);
> lua_settable(luaVM, LUA_GLOBALSINDEX); /* register it with given name */
> lua_setfenv(luaVM, -2);
> -------------------------------------
>
> is vastly different from
>
> -------------------------------------
> luaopen_string (luaVM);
> luaopen_math (luaVM);
>
> lua_newtable(luaVM);
> lua_pushstring(luaVM, "core");
> lua_pushvalue(luaVM, -2);
> lua_settable(luaVM, LUA_GLOBALSINDEX); /* register it with given name */
> lua_setfenv(luaVM, -2);
> -------------------------------------