[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: "Wim Couwenberg" <w.couwenberg@...>
- Date: Wed, 24 Sep 2003 22:21:50 +0200
> but where can I specify the name of the namespace?
Add the following lines:
/* prepare environment */
lua_newtable(L);
/* add some data here ... */
> /* store it in the C globals */
> lua_pushstring(L, my_namespace_name);
> lua_pushvalue(L, -2);
> lua_settable(L, LUA_GLOBALSINDEX);
/* set it as the loaded chunk's environment
(it will act as the chunk's table of globals) */
lua_setfenv(L, -2);
/* run chunk */
lua_call(L, 0, 0);
--
Wim