Copy link to clipboard
Copied
Not the highest priority but I'd like to better organize my source files. Is it possible to require Lua files from subdirectories? I've tried "require foo/bar" and "require foo.bar" but get an error. I also tried looking at Lua's package.path but Lr seems to hide that (?).
I assume I can do this with the require() in John Ellis's debugging toolkit but I'm not looking to require something from a common, peer directory and I wonder if there's something built-in that's lighter weight?
db
The built-in "require" doesn't do search paths or subdirectories, unfortunately. That's why I ended up writing Require.lua in the toolkit.
I don't know why the "package" module isn't included in the LR SDK environment, but it may be because LR has its own method of managing loaded modules and plugins. "package" is available internally inside LR, which you can see by doing the following:
import "LrHiddenLua".package
(you'll need the debugging toolkit installed). I've never tried it from inside a p
...Copy link to clipboard
Copied
The built-in "require" doesn't do search paths or subdirectories, unfortunately. That's why I ended up writing Require.lua in the toolkit.
I don't know why the "package" module isn't included in the LR SDK environment, but it may be because LR has its own method of managing loaded modules and plugins. "package" is available internally inside LR, which you can see by doing the following:
import "LrHiddenLua".package
(you'll need the debugging toolkit installed). I've never tried it from inside a plugin.
Copy link to clipboard
Copied
Out of curiosity, John, do you have any methods for dealing with required modules in other directories to the main plugin when compiling?
thanks.
Copy link to clipboard
Copied
FWIW, I include '.' in the require.path pathlist then compile everything into a release .lrplugin folder using a bash script. This seems to work and it's simple. Toying with using make but I'm honestly not sure it warrants it.
Copy link to clipboard
Copied
I include '.' in the require.path pathlist then compile everything into a release .lrplugin folder using a bash script. This seems to work and it's simple. Toying with using make but I'm honestly not sure it warrants it.
This is exactly what I do. The script compiles the Lua modules into a temp folder, copies any other necessary resources (images, settings files, etc), then zips up the temp folder.
Copy link to clipboard
Copied
kimaldis​, for what it's worth, I started a recent project with a gnu make file and, although I'm comfortable with make, it was overkill. I remembered that Make isn't really for automation, it's for managing dependencies in big projects - traditionally to cut down on compile times. None of that applies to most LR plugin projects. So, I just backed off to a simple bash script and it was the right choice. You are welcome to take mine and run with it if suits you:
LrSlide/build.sh at master · DaveBurns/LrSlide · GitHub
db
Copy link to clipboard
Copied
I haven't tried it just yet but a better solution might be Growl. It can be configured to watch for changes in source files & recompile automatically.
Copy link to clipboard
Copied
Beg pardon; Gulp
Copy link to clipboard
Copied
Well, true but then again, how many source files do you have? My IDE sees a .lua file change and runs the bash script in a split second. The complexity is low and bash comes preinstalled (at least on Macs).
db
Copy link to clipboard
Copied
a gulpfille is really no harder than a shell script.