Re: Binding modules loaded by "require"?
Kristoffer Danielsson <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
Thanks for your reply. I've read the documentation, but I don't quite follow. If I load "C:\MyScript.lua" and do my luabind stuff: luabind::open(L); bind "foo" etc... And then, inside this MyScript.lua, I want to get access to another library: require 'extra.mylib' -- Loads C:\extra\mylib.lua... Now, inside mylib.lua I want to access my C++ function "foo". You mention "preload", but where should I initialize it - and how? Thanks again! Date: Wed, 16 Dec 2009 20:16:20 -0800 From: [email protected] To: [email protected] Subject: Re: [luabind] Binding modules loaded by "require"? 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"]". _________________________________________________________________ Nya Windows 7 - Hitta en dator som passar dig! Mer information. http://windows.microsoft.com/shop ------------------------------------------------------------------------------ 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