Thread Tools Display Modes
Prev Previous Post   Next Post Next
01-17-10, 02:01 PM   #1
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Can't figure out why this is suddenly not working....

lua Code:
  1. InIg = InIg or CreateFrame("Frame")
  2. InIg:RegisterEvent("VARIABLES_LOADED")
  3. InIg:SetScript("OnEvent", function(self, event, ...) if InIg[event] then return InIg[event](self, event, ...) end end)
  4.  
  5. function InIg:VARIABLES_LOADED(event)  
  6.     self.ignore = self.ignore or {}
  7.     print("self.ignore created")
  8. end
  9.  
  10. -- CHECK IGNORE STATUS
  11. function InIg:ignoreCheck(_,_,sender)
  12.     for i = 1, #(InIg.ignore) do
  13.         if InIg.ignore[i] == sender then
  14.             print(sender.. " is ignored.")
  15.             return true -- sender is on ignore list
  16.         end
  17.     end
  18.     return false -- sender is not on ignore list
  19. end
  20.  
  21. -- HOOK CHATS
  22. local events = {
  23.     "CHAT_MSG_CHANNEL",
  24.     "CHAT_MSG_WHISPER",
  25.     "CHAT_MSG_EMOTE",
  26.     "CHAT_MSG_BATTLEGROUND",
  27.     "CHAT_MSG_BATTLEGROUND_LEADER",
  28.     "CHAT_MSG_GUILD",
  29.     "CHAT_MSG_PARTY",
  30.     "CHAT_MSG_RAID",
  31.     "CHAT_MSG_RAID_LEADER",
  32.     "CHAT_MSG_SAY",
  33.     "CHAT_MSG_RAID_WARNING",
  34.     "CHAT_MSG_YELL",
  35.     "CHAT_MSG_OFFICER"}
  36.    
  37. for _,k in ipairs(events) do
  38.     ChatFrame_AddMessageEventFilter(k, InIg.ignoreCheck)
  39. 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.

Last edited by Sythalin : 01-17-10 at 02:03 PM. Reason: code revision, still not helping
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Can't figure out why this is suddenly not working....


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off