What is the correct and current way to structure a lua plugin with multiple modules?
I have created a Wireshark dissector in lua and this is working. I now need to extend the functionality and so first I have split the single .lua file into multiple modules.
I saw this question, which helped me get the use of the package path correct, as previously I was following examples using package.prepend_path, which I understand has been removed. This basically breaks every example I can find for anyone getting started with Wireshark and lua!
https://ask.wireshark.org/question/34...
Now the I have my dissector split into multiple modules, I have further problems.
If I go to Help->About->Plugins, I see every module in my code listed as a separate plugin. I am not sure if this is correct or not. However, Ctrl-Shift-L loads every module in alphabetical order. When it reaches my main lua file, my main file then loads all the modules as it should. Is this expected behaviour? Some of my modules depend on others, so the load order is important. Am I meant to be using require in my lua scripts (I am at the moment)? It seems like Wireshark is trying to load all the lua sub-modules for me, in which case I don't need to use require, but will have to hack the load order by alphabetically naming the files so they load in the correct sequence. This can't be right. Perhaps I am meant to keep my sub-modules outside the plugins folder. I have searched pretty hard for answers, but haven't found anything that has helped, except the link above that got things going.
At the moment, my main lua module is at C:\Program Files\Wireshark\plugins\mypluginname\init.lua. My sub-modules are in a 'files' folder beneath this.
Can anyone point me to the correct way to structure the files in a Wireshark lua dissector? - What to name the main module. Does it matter? - Where to place the sub-modules. Within the plugins folder structure or elsewhere? - Whether to use require within the main lua file or whether to let Wireshark load them from its recursive search of the folders.
Perhaps there are docs that explain this. If so, a link would be great and apologies that I failed to find it.
18589: Lua Personal vs Global Plugin Failure
17212: Lua plugin loading order undefined
10.1. Introduction
I think it's documented somewhere or in an issue that .lua files in sub directories are loaded.
It does load because I've tested it but don't remember if/where it's documented.