Page 1 of 1

require problems

Posted: Fri Dec 13, 2013 6:07 am
by grimm
Hi Thomas,

I was playing around with moving some of the Lua code to a module and ran into a small problem. It appears that require can only find module files in the Octane base directory. I have set up a script directory but if I move the module to that directory Lua can no longer find it. Otherwise I'm having fun with Lua. :)

Re: require problems

Posted: Fri Dec 13, 2013 8:05 am
by stratified
hi there,

As a workaround, you could add the path to your directory manually to the package.path variable (this is where Lua searches for modules):

Code: Select all

-- add the directory to the search path, a bit hacky I know :(
package.path = "/home/thomas/dev/?.lua;" .. package.path
require("test")
test.p(10)
If you want to know more about module loading in Lua, here are the nitty gritty details in:

http://www.lua.org/manual/5.1/manual.html#5.3

I'll make sure we add the configured script directory automatically to the search path in the next release (1.23).

cheers,
Thomas

Re: require problems

Posted: Sat Dec 14, 2013 8:27 pm
by grimm
Thanks Thomas, that worked. :D