Recently, I'm trying to look through a WOW addon called VenturePlan, which calculates the result of your command table quest.
It's a simple addon with almost pure '.lua' files. They are 'Collector.lua', 'Loader.lua', 'MissionList.lua', 'MissionView.lua', 'VenturePlan.toc', 'vs-spells.lua', 'vs.lua', 'Widgets.lua', 'Libs/Evie.lua'.
I have a little knowledge of programming, like python and c. But I haven't written addons for WOW. I got stuck at the very beginning of this addon.
Almost every file has a piece of code
local _, T = ...
local EV = T.Evie
To my understanding, those code at the very beginning, are usually some variable declaration, or module import. Here, seems the author passed some value to 'T', but I can't figure out where this happens, and it's not even a callable function, it's in a .lua file.
Also, I could not find the entry point. It seems 'Loader.lua' will be loaded first, but it never return anything interesting.
So, where does the 'T' come from? and what's the structure of it, where it's defined?
The addon is here https://www.townlong-yak.com/addons/venture-plan
Lua chunks in a file are loaded as a function. WoW will call those functions providing two arguments. First argument is the addon's name and the second one is a table shared among all files of your addon. That way you don't have to use the global environment to share data between your files.
local _, T = ...
will store those two arguments in two local variables. _
is usually to name unused variables. luacheck for example won't raise warnings for unused variables named _
print(_, T)
in all those files and you should get the same string and table.