View Single Post
03-10-22, 07:40 AM   #3
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,360
WoW addons use a Table of Contents <addonName>.toc file to instruct the client to load files.

If you open an existing addon you will see a number of files referenced by their filenames in the .toc file.

That's the way addons can load multiple files in the general case.
There's some nuance there, xml files can load other xml or lua files themselves using some special xml tags/directives, so some addon might reference an xml file in the .toc and that xml then loads other files.

Now about sharing information between different files comprising an addon.

There's two ways to do that, either
- put some methods or data in the global namespace that all addons share. This is not recommended and aside for very specific situations not required.
- use the vararg passed by the wow client to all lua files loaded by an addon .toc that provides those files with the addon name and a shared table.
You will typically see a line such as
Code:
local addonName, addonTable = ...
at the top of each lua file.
You can then put stuff (methods or data) that you want accessed from another file into that addonTable.
  Reply With Quote