lua-users home
lua-l archive

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


> If you want to use require, you could always do (after calling
> luaL_openlibs()):
> 
> 	lua_getglobal(L,"package");
> 	lua_getfield(L,-1,"preload");
> 	lua_pushcfunction(L,luaopen_nameofyourmodule);
> 	lua_setfield(L,-2,"nameofyourmodule");

It's simpler to use luaL_requiref:
	luaL_requiref(L,"nameofyourmodule",luaopen_nameofyourmodule)

See http://www.lua.org/manual/5.2/manual.html#luaL_requiref