Quantcast
WoWInterface - View Single Post - Logging all XP gains
View Single Post
06-15-20, 10:52 AM   #2
Ketho
A Molten Giant
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 945
You need to wait until ADDON_LOADED until your savedvariables are available
https://wow.gamepedia.com/Saving_var..._game_sessions

Something like this
Lua Code:
  1. local Congrats_EventFrame = CreateFrame("Frame")
  2. local defaults = {
  3.     TotalXP = 0
  4. }
  5.  
  6. Congrats_EventFrame:RegisterEvent("ADDON_LOADED")
  7. Congrats_EventFrame:RegisterEvent("CHAT_MSG_COMBAT_XP_GAIN")
  8. Congrats_EventFrame:SetScript("OnEvent",
  9.     function(self, event, ...)
  10.         if event == "CHAT_MSG_COMBAT_XP_GAIN" then
  11.             -- do stuff
  12.         elseif event == "ADDON_LOADED" then
  13.             local addon = ...
  14.             if addon == "XPlogger" then
  15.                 XPLogger = XPLogger or defaults
  16.                 self:UnregisterEvent(event)
  17.             end
  18.         end
  19.     end)
  Reply With Quote