View Single Post
04-30-17, 08:40 PM   #5
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
OnInitialize() only fires once per addon or module, meaning it fires once for the addon, and once for each and every loaded module. Even if you /reloadui it still won't fire again. It would be the equivalent of registering for ADDON_LOADED (for saved variables) and PLAYER_ENTERING_WORLD (for miscellaneous other start up code) and then unregistering both events. OnInitialize() just makes that process a bit cleaner.

OnEnable() is somewhat like PEW, keeping in mind that it is never unregistered. Each time you /reloadui, OnEnable() fires.

If you are not getting the correct currency information, that probably means the game cannot provide that information ... yet.

With Ace3, you register events and library callbacks in OnEnable(). And handling events is always through a function, then register for PLAYER_MONEY in currency.lua's OnEnable(), and immediately call that function from OnEnable().

In your PLAYER_MONEY handler function, have a line that reads:
Lua Code:
  1. db.realm[name].money = GetMoney() -- or whatever you actually need
  Reply With Quote