How to set Lua file load path in defold?

how to set lua file load path in defold? can I set lua file load path by use package.path or package.cpath?

We replace the standard loaders with our own loader:

This loader explicitly loads files from within the game archive. Our build pipeline also inspects all script files and picks up all calls to require() to detect which Lua modules to include. This is good because we only include Lua files which are actually used, but it is bad since it doesn’t really allow you to load other Lua files using require() without also tripping up our build pipeline.

You can of course add your own loaders to package.loaders but then you also need to fool our build pipeline.

Another thing to consider is compatibility between platforms. You will not be able to require() Lua files from anywhere on all platforms.

So I guess before we go on I’d like to know more about what it is you wish to achieve?

1 Like

I want to have a shared folder on my local drive that I can require files from in multiple Lua and Defold projects. These files are independent and testable outside a Defold project. Is there a way to share files without having to create and publish a library project to github? At the moment, I am having to link files to have them shared but then the requires stop working when I run from the command line.

You can have linked folders within your project.
I use it when developing extensions in one project, and testing it in another project.

2 Likes