lua-users home
lua-l archive

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


> > 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