lua-users home
lua-l archive

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


It was thus said that the Great Luiz Henrique de Figueiredo once stated:
> > 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

  Ah.  I'm still using 5.1 [1] so I didn't realize that function existed. 
Thanks.

  -spc

[1]	I'm a bit hesitant to upgrade.  I'm using 5.1 at work, and I'd hate
	to lose the option of using LuaJIT (not that I'm really using it
	now, but it's still an option for some of our platforms).