Organizing code and Include/require external modules

Hi everyone,

I was wondering if there were any thoughts on how to organize code for maximum re-usability especially when thinking about sharing and (not to forget) maintaining functionality across multiple projects.
I know that in principle Halions version of Lua does support the “require” function, which would be exactly what I’m looking for, alas for that I don’t see a way to get around relying on actual external lua files that would have to be shipped out to the users system. So I’m wondering if there is a recommended workflow here.
I was thinking if maybe multiple Lua Script objects can be helpful with this, or if maybe the library creator would allow me to “bake” external Lua files into a container that can be protected for deployment, but I’ve not really found a good answer so far.
Ideally I’d like to work with as many separate external lua files as I want and then have the whole thing compiled into a container when I export the program, but any other suggestions would be welcome.

Hi Kerphelio,

I think it depends on how you want to distribute your programs.

If you plan to build vstsound container then it should be fine as the Library Creator should collect and include all external script files that are needed for the programs. Same way it does with samples. You can protect the scripts if you want to.

I have only tried require function briefly and it worked fine. I haven’t tried to build a library that would make use of modules yet but I believe they should be also collected by Library Creator as “dependent files”.

***Regarding your other thread about debugging, I’d like to know as well.

Thanks misohoza,

that sounds like I’ll definitely do some little test project with library creator. I can see how it would include lua files referenced by the lua script module, but I’m a little doubtful it would “know” about other files that are tied to the project only by “require” statements - unless it really is sophisticated enough to parse the lua files for them, which of course would be awesome.
Hmm, or I’ll just manually drag all the files in, duh. We’ll know soon enough… :ugeek:

UPDATE: Yup, that seems to have worked. I created a little test project that called functions from and across multiple .lua files. Then I created a library and manually dragged all the files into the Library Creators “content” field, just like presets. It then automatically creates a “script” folder. Once the container was created, I tested on a different PC and all the scripted functionality seems to be working just as expected. Very nice!

This is a pretty smart idea. When you do this does the parameters created in the external lua files appear in halion to be mapped to the GUI or did you plan to use this in a different way?

Everything, parameters and all, was working as it was before I created a Library.