Re: Binding modules loaded by "require"?
Jason McKesson <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
On 12/16/2009 2:55 PM, Kristoffer Danielsson wrote: > If I load a module inside my luabind-controlled lua-script: > require "path/mylib" > > ...then I want to bind my C++ functions to "mylib.lua". How do I do that? > > As it is now, the library does not know of my C++ classes/functions, > which basically makes modularization worthless. > > Thanks! The Lua manual explains the functioning of require quite well. You can find what you're looking for here: http://www.lua.org/manual/5.1/manual.html#5.3 Basically, what you want is to register a loading function with Lua. Just use Luabind to register a function, then place this function in the "package.preload" table under the entry of whatever you want the module to be named. So if you want "path/mylib" to be the name of the module, you would put the loader function in "package.preload["path/mylib"]". ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ luabind-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/luabind-user