Page 1 of 1

Organizing code and Include/require external modules

Posted: Tue Jan 30, 2018 3:02 am
by Kerphelio
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.

Re: Organizing code and Include/require external modules

Posted: Tue Jan 30, 2018 12:39 pm
by misohoza
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.

Re: Organizing code and Include/require external modules

Posted: Wed Jan 31, 2018 7:45 am
by Kerphelio
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:

Re: Organizing code and Include/require external modules

Posted: Fri Feb 02, 2018 11:02 am
by Kerphelio
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!

Re: Organizing code and Include/require external modules

Posted: Thu Feb 08, 2018 2:52 am
by abject39
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?

Re: Organizing code and Include/require external modules

Posted: Wed Feb 14, 2018 5:57 am
by Kerphelio
Everything, parameters and all, was working as it was before I created a Library.