lua Code:
InIg = InIg or CreateFrame("Frame")
InIg:RegisterEvent("VARIABLES_LOADED")
InIg:SetScript("OnEvent", function(self, event, ...) if InIg[event] then return InIg[event](self, event, ...) end end)
function InIg:VARIABLES_LOADED(event)
self.ignore = self.ignore or {}
print("self.ignore created")
end
-- CHECK IGNORE STATUS
function InIg:ignoreCheck(_,_,sender)
for i = 1, #(InIg.ignore) do
if InIg.ignore[i] == sender then
print(sender.. " is ignored.")
return true -- sender is on ignore list
end
end
return false -- sender is not on ignore list
end
-- HOOK CHATS
local events = {
"CHAT_MSG_CHANNEL",
"CHAT_MSG_WHISPER",
"CHAT_MSG_EMOTE",
"CHAT_MSG_BATTLEGROUND",
"CHAT_MSG_BATTLEGROUND_LEADER",
"CHAT_MSG_GUILD",
"CHAT_MSG_PARTY",
"CHAT_MSG_RAID",
"CHAT_MSG_RAID_LEADER",
"CHAT_MSG_SAY",
"CHAT_MSG_RAID_WARNING",
"CHAT_MSG_YELL",
"CHAT_MSG_OFFICER"}
for _,k in ipairs(events) do
ChatFrame_AddMessageEventFilter(k, InIg.ignoreCheck)
end
Getting the following error:
Code:
Message: Interface\AddOns\InIg\InIg.lua:67: attempt to get length of field 'ignore' (a nil value)
Time: 01/17/10 13:56:26
Count: 30
Stack: Interface\AddOns\InIg\InIg.lua:67: in function `filterFunc'
Interface\FrameXML\ChatFrame.lua:2511: in function `ChatFrame_MessageEventHandler'
Interface\FrameXML\ChatFrame.lua:2318: in function `ChatFrame_OnEvent'
[string "*:OnEvent"]:1: in function <[string "*:OnEvent"]:1>
Error is at line 12 in my paste above.
I added the
print("self.ignore created") and finding that loading seems to be skipping
VARIABLES_LOADED because it never prints on login/reload. I've used this setup a dozen times now with no issues, haven't noticed any typos and the frame creation/event registration are the first things to happen in the file.