View Single Post
04/04/14, 01:46 AM   #5
Xrystal
caritas omnia vincit
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 369
Ok, I think I can see where you are going wrong.

If you bear in mind that some information is only accessible after the addon is loaded or the player is activated things will become easier to implement.


If you take a look at my gatherer addon you will see that at the top of the file I have some addon variables and at the bottom I have some functions that are using the event system and are called by the event system. You could almost copy those and just adjust for your addon to get it to work.


Try something like the following.


local addon_name = "..."
local addondata = {}


local function init_addondata()
addondata=zo_savedvars:new(....)
end


local function player_activated(eventid)
--Player is active and most things are available now
end


local function addon_loaded(eventid, addon)
if addon == addon_name then init_addondata()
EVENT_MANAGER:RegisterForEvent(addon_name,EVENT_PLAYER_ACTIVATED,player_activated)
end
end


EVENT_MANAGER:RegisterForEvent(addon_name,EVENT_ADDON_LOADED,addon_loaded)




Hope that helps. I use this as the base of all my addons.

Last edited by Xrystal : 04/04/14 at 02:12 AM.
  Reply With Quote