lua-users home
lua-l archive

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


Hello Jason:

It's easiest to open all of the standard libraries at once by calling luaL_openlibs(L). However, if you want to open the package library individually, you can do it like this:

 lua_pushcfunction(L, luaopen_package);
 lua_pushliteral(L, "package");
 lua_call(L, 1, 0);

The statements above push luaopen_package as a C function on the Lua stack, push the library name ("package") as an argument, and tell Lua to call the function, not leaving any return values on the stack. This is the way that luaL_openlibs opens each of the standard libraries.

I hope this helps.

--
Matt Campbell
Lead Programmer
Serotek Corporation
www.freedombox.info
"The Accessibility Anywhere People"