Hello all. I have a question about require, include and dofile I guess.
I have basically the following folder structure:
my_script/
my_script.lua
lib/
my_lib.lua
my_helpers.lua
I’d like to import my_helpers.lua into both my_script.lua and my_lib.lua. The import into my_script.lua works fine. No problem there.
When I use require("math_helpers") to try to import into my_lib.lua I get the following error:
### SCRIPT ERROR: load fail
/home/we/dust/code/carter/circles/lib/libCircles.lua:17: module 'math_helpers' not found:
no field package.preload['math_helpers']
...
no file './math_helpers.lua'
no file './math_helpers/init.lua'
...
no file './math_helpers.so'
Because my_lib.lua and my_helpers.lua are in the same folder, I would have assumed that the ./math_helpers.lua would have matched. I then thought that maybe it was relative to my_script.lua so I tried require("lib/math_helpers") but got the same type of error.
Is there a supported way to do this? I know I can use dofile but I’d like to be able to provide a relative path.
Thanks.