require problems

Forums: require problems
Forum for OctaneRender Lua scripting examples, discussion and support.

require problems

Postby grimm » Fri Dec 13, 2013 6:07 am

grimm Fri Dec 13, 2013 6:07 am
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. :)
Linux Mint 20 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 460.56
User avatar
grimm
Licensed Customer
Licensed Customer
 
Posts: 1321
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

Re: require problems

Postby stratified » Fri Dec 13, 2013 8:05 am

stratified Fri Dec 13, 2013 8:05 am
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
User avatar
stratified
OctaneRender Team
OctaneRender Team
 
Posts: 945
Joined: Wed Aug 15, 2012 6:32 am
Location: Auckland, New Zealand

Re: require problems

Postby grimm » Sat Dec 14, 2013 8:27 pm

grimm Sat Dec 14, 2013 8:27 pm
Thanks Thomas, that worked. :D
Linux Mint 20 x64 | Nvidia GTX 980 4GB (displays) RTX 2070 8GB| Intel I7 5820K 3.8 Ghz | 32Gb Memory | Nvidia Driver 460.56
User avatar
grimm
Licensed Customer
Licensed Customer
 
Posts: 1321
Joined: Wed Jan 27, 2010 8:11 pm
Location: Spokane, Washington, USA

Return to Lua Scripting


Who is online

Users browsing this forum: No registered users and 4 guests

Thu Mar 28, 2024 10:13 pm [ UTC ]