Thread: Slash commands
View Single Post
04-03-09, 09:23 AM   #2
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
There are quite a few ways of doing it, but this is what I do.

Add a saved Variables field to the toc:

Code:
## SavedVariables: MyAddonSV
Create an event handler for ADDON_LOADED and assign a table to MyAddonSV if it doesn't have one, and optionally set up defaults.
ie.
Code:
local eframe = CreateFrame("Frame")
eframe:RegisterEvent("ADDON_LOADED")
eframe:SetScript("OnEvent", function(self, event, addon)
   self:UnregisterEvent("ADDON_LOADED")
   self:SetScript("OnEvent", nil)
   MyAddonSV = MyAddonSV or {}
end)
MyAddonSV now operates like any other table except it's stored on reload.
  Reply With Quote