View Single Post
09-03-11, 07:48 AM   #36
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Modules are a little bit of work, a little too much for me to go in-depth on (too little time these days). Best bet is to find an addon that already uses modules (Postal, Mapster, etc), but since you're not too familiar with Ace/Lua yet it may take some time to understand the system, especially since most samples will contain a lot of extra stuff. Took me a few days of heavy tinkering to get my first modules to work

Before you start on modules, I'd recommend taking a look at this Ace3 addon guide. It'll provide a nice overview of the basic Ace functionality so you can better grasp how the system operates.

For modules, basically you can create a new .lua file for your module, maybe store it under a Modules folder, and reference this in your .toc. In this new module file, you can get your Ace Addon object, as well as create your new module object, like so:

Code:
local MyAddon = LibStub("AceAddon-3.0"):GetAddon("MyAddon")
local MyModule = MyAddon:NewModule("MyModule")
The module will then work similar to a Core.lua file would. It can reference MyAddon:Etc() functions, as well as have it's own MyModule:Etc() functions. It can have it's own options, defaults, and config sections, each which need to get registered and accounted for in your Core.lua and Config.lua files.
  Reply With Quote