View Single Post
06-15-16, 10:44 PM   #5
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,336
If you need a module to load while the core is loading, you can set LoadOnDemand in the ToC of the module. This allows the core to call LoadAddOn() when it needs the module to be loaded. I personally wouldn't recommend this route and would instead promote better core and module designs where race conditions don't exist.

Another thing to look at is if its actually necessary to split up an addon into other addons as modules. This should only be reserved for addons that want to include separate optional features or plugins. A better way to modularise an addon as part of having clean code is to put different sections of the addon as different files in the same addon, linked together by the ToC.

A key feature to modules within a addon is the shared table given to all Lua files of an addon. You can use this table to build and pass along an internal API that is more secure than using globals. To access this, I usually have this at the top of every Lua file.
Code:
local Name,Addon=...;
This stores the addon's folder name in Name and the shared table in Addon.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 06-15-16 at 10:59 PM.
  Reply With Quote