2x Error loading WTF\Account\KALDARA\SavedVariables\MacroParser-1.0.0.lua
This only occurs on the first execution of the addon with no saved data file yet in existence.
This is my TOC file.
## Interface: 90100
## Title: MacroParser
## Author: KaldaraWorks
## Version: 1.0.0
## SavedVariables: MP_SavedData
MP_Initialize.lua
MacroParser.lua
This is the ONLY place where MP_SavedData appears in my code (verified by search).
function f.Initialization()
local frame = CreateFrame('Frame')
frame:RegisterEvent('ADDON_LOADED')
frame:RegisterEvent('PLAYER_ENTERING_WORLD')
frame:RegisterEvent('PLAYER_LEAVING_WORLD')
frame:SetScript("OnEvent", function(self, event, ...)
if (event == 'ADDON_LOADED') then
if MP_SavedData and
(MP_SavedData.SysEmotesSize or 0) > 0 and
(MP_SavedData.SysCmdsSize or 0) > 0 then
d.SysEmotes = CopyTable(MP_SavedData.SysEmotes)
d.SysEmotesSize = MP_SavedData.SysEmotesSize
d.SysCmds = CopyTable(MP_SavedData.SysCmds)
d.SysCmdsSize = MP_SavedData.SysCmdsSize
else
MP_SavedData = {}
end
elseif (event == 'PLAYER_ENTERING_WORLD') then
if MP_SavedData
and MP_SavedData.SysCmdsSize and MP_SavedData.SysCmdsSize > 0
and MP_SavedData.SysEmotesSize and MP_SavedData.SysEmotesSize > 0 then
d.AddOnCmds, d.AddOnCmdsSize = f.GetAddOnCmdsList()
elseif f.SysCmdsEligible("Initialization") then
MP_SavedData = {}
d.SysEmotes, d.SysEmotesSize = f.GetEmotesList()
d.SysCmds , d.SysCmdsSize = f.GetSysCmdsList()
d.AddOnCmds, d.AddOnCmdsSize = f.GetAddOnCmdsList()
else
MP_SavedData = {}
end
elseif (event == 'PLAYER_LEAVING_WORLD') then
MP_SavedData = CopyTable(d)
end
end)
end
If I run it a second time, it works just fine.
I know I could just run it a second time and be done with it but this is going to eventually be a distributed addon and it feels sloppy to have this happen. None of the other addons I have did this on first run and I’d like to get rid of the error.