Hide Select '.lua' files from Gadget Dropdown Menu

This section is for general discussion about Gadgets
Post Reply
CNCDaveToo
Posts: 26
Joined: Mon Jan 22, 2018 3:47 am
Model of CNC Machine: ShopBot Desktop
Location: Leesburg, Virginia, USA

Hide Select '.lua' files from Gadget Dropdown Menu

Post by CNCDaveToo »

After passing 500 lines of code in my gadget, I finally sat down and separated out the drawing of the objects on their respective layers and the generation of the toolpaths into their own .lua files for readability and maintainability, leaving me with three files: Seg_Calc.lua, AddRowLayers.lua, and AddRowToolpaths.lua .

Behavior prior to separating out the files (when the only file was Seg_Calc.lua)

1. Click on "Gadgets" menu
2. Click on "Seg Calc" item -- gadget runs


Behavior after creating the two utility files in the Seg_Calc folder:

1. Click on "Gadgets" menu
2. Click on "Seg Calc >" item (item now creates next level dropdown instead of running the gadget
3. See a dropdown menu with:
AddRowLayers
AddRowToolpaths
Seg Calc

4. Click on "Seg Calc" item -- gadget runs

I'd prefer if the utility files didn't appear in the dropdown (and trigger creation of the next level dropdown menu).

I moved AddRowLayers.lua and AddRowToolpaths.lua into a "Utilities" sub-folder, hoping that would hide it from the menu.

Behavior after moving utility files into "Utilities" sub folder:

1. Click on "Gadgets" menu
2. Click on "Seg Calc>" item
3. See a dropdown menu with:
Seg Calc
Utilities >


(if you click on the "Utilities" item, you will see a further dropdown with:
AddRowLayers
AddRowToolpaths


Is there any way to tell VCP to ignore these utility files? (or to just look into the first level directory?)
Be kind.

User avatar
Adrian
Vectric Archimage
Posts: 10876
Joined: Thu Nov 23, 2006 2:19 pm
Model of CNC Machine: ShopBot PRS Alpha 96x48
Location: Surrey, UK

Re: Hide Select '.lua' files from Gadget Dropdown Menu

Post by Adrian »

It treats the folders as levels in the menu, that's by design or the menu would get cluttered very quickly and you would need unique names for every file.

Do the library/module files have to be .lua files? I haven't done any lua work for a while but nearly every other language I use doesn't care what the name of the files are as long as they are specified in full if the default extension is not used.

Personally I don't bother that much about separating out code that is used in multiple places as the merging happens as part of the version control. There's only one copy of the code at that level but when I generate the code it's all included at that stage. With interpreted languages I've run into issues many times when a support file has changed and an earlier program fails because of that. Treating them as merged, pre-compiled programs stops that.

CNCDaveToo
Posts: 26
Joined: Mon Jan 22, 2018 3:47 am
Model of CNC Machine: ShopBot Desktop
Location: Leesburg, Virginia, USA

Re: Hide Select '.lua' files from Gadget Dropdown Menu

Post by CNCDaveToo »

Thanks Adrian. You're right that the files don't need to be ".lua", and after thinking about it, I can see how the Vectric folks would want to keep things simple by just finding any ".lua" files for display purposes -- this has the added benefit of allowing a gadget to easily have different public-facing utilities without mucking about too much in the UI (a feature I may exploit in a future version of my gadget).

Prior to my post, I had done the naming of the utility files ".lu", but my inner OCD voice grumbled and muttered about "hoping for a cleaner solution". After having a cup of coffee and a long chat with my inner OCD, he's agreed to just not look. :)
Be kind.

Post Reply