Originally Posted by Ketho
|
Thanks for your kind help and quick response. Does this mean that any logic in relation to interacting with that variable needed to come after that event has fired?
i.e.
Lua Code:
local Congrats_EventFrame = CreateFrame("Frame")
local defaults = {
TotalXP = 0
}
Congrats_EventFrame:RegisterEvent("ADDON_LOADED")
Congrats_EventFrame:RegisterEvent("CHAT_MSG_COMBAT_XP_GAIN")
Congrats_EventFrame:SetScript("OnEvent",
function(self, event, ...)
if event == "CHAT_MSG_COMBAT_XP_GAIN" then
local arg1 = ...
local xpgained = string.match(string.match(arg1, "%d+ experience"), "%d+")
print('--xp gained--')
print(UnitLevel("player"), xpgained, date("%d/%m/%y %H:%M:%S"))
print('---')
-- this doesn't seem to get saved or displayed?
XPLogger.TotalXP = XPLogger.TotalXP + tonumber(xpgained)
print('Total XP' .. XPLogger.TotalXP)
elseif event == "ADDON_LOADED" then
local addon = ...
if addon == "XPlogger" then
print('XPLogger loaded')
XPLogger = XPLogger or defaults
self:UnregisterEvent(event)
end
end
end)