Hi all,
I am making a small addon for Classic that logs all XP gains to a SavedVariables file that I can then parse later for analysis. I am struggling a bit with the SavedVariables piece. Hoping someone can help.
XPlogger.toc
Lua Code:
## Interface: 11303
## Title: XPLogger
## Author: eightfive labs
## Notes: Logs all XP gains to a file for analysis later
## Version: 0.0.1
## SavedVariablesPerCharacter: XPLogger
main.lua
main.lua
Lua Code:
local Congrats_EventFrame = CreateFrame("Frame")
local defaults = {
TotalXP = 0
}
XPLogger = XPLogger or defaults
Congrats_EventFrame:RegisterEvent("CHAT_MSG_COMBAT_XP_GAIN")
Congrats_EventFrame:SetScript("OnEvent",
function(self, event, ...)
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('---')
XPLogger.TotalXP = XPLogger.TotalXP + tonumber(xpgained)
print('Total XP' .. XPLogger.TotalXP)
end)
However, I am not seeing the SavedVariables file being written and the XPLogger.TotalXP is reset on /reload.
Any help would be appreciated.