FYI your code is seriously horrid. Whilst that usually wouldn't matter (most events fire infrequently), you need to consider that the combat log event fires so often that it can overtake polling (OnUpdate), so performance needs to be called into question.
Here is a simple approach which assumes the only event you want to register is the combat log:
Code:
local myTable = {}
local _SPD = CreateFrame("Frame")
_SPD:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
_SPD:SetScript("OnEvent", function(_, _, _, event, _, _, sourceName, _, _, _, _, _, _, _, spellName)
if event == "SPELL_AURA_APPLIED" and UnitIsUnit(sourceName, "player") then
if not myTable[spellName] then
print("It exists")
else
myTable[spellName] = {}
print("Created")
end
end
end)
Here is an approach that assumes you want to register multiple events to the given frame:
Code:
local myTable = {}
local _SPD = CreateFrame("Frame")
_SPD:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
_SPD:SetScript("OnEvent", function(frame, event, ...)
frame[event](frame, event, ...)
end)
function _SPD:COMBAT_LOG_EVENT_UNFILTERED(_, _, _, event, _, _, sourceName, _, _, _, _, _, _, _, spellName)
if event == "SPELL_AURA_APPLIED" and UnitIsUnit(sourceName, "player") then
if not myTable[spellName] then
print("It exists")
else
myTable[spellName] = {}
print("Created")
end
end
end