[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: Wed, 24 Sep 2003 23:48:25 +0300
> > 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);
yes, it works, but inside the loaded functions do not see standard modules
like string, math and so on.
Best regards,
Dmitriy Iassenev