Quantcast WoWInterface - View Single Post - separate modules within 1 addon
View Single Post
Unread 11-08-12, 06:32 PM   #5
A Pyroguard Emberseer
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,263
Whenever I need to have a set of functions specific to a module in the private table, I usually have a table specifically for the module and store it within the private table. This would produce something like the following.

local name,addon=...;
local module={};-- Create module table
addon.Module1=module;-- This stores our local module table as "Module1" of the addon table

module.Variable="Some value";

function module.Enable()
-- Enable module here

function module.Disable()
-- Disable module here (if you want to be able to)

function module.DoSomething()
-- Any other stuff you want to do
local name,addon=...;
addon.Module1.Enable();-- Enable Module1

Note you can use the private table like any other table and being shared among all Lua files of your addon opens it up to easily be used to create an internal API in whatever structure you want.
"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 : 11-08-12 at 06:38 PM.
SDPhantom is offline   Reply With Quote