Thread Tools Display Modes
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
01-17-10, 02:56 PM   #2
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Are you using the frame itself as a saved variable?
  Reply With Quote
01-17-10, 02:59 PM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
First, disable any chat frame addons. Many chat frame addons increase the number of lines retained, which wipes all messages currently in the frame when that action is performed. It's possible your print is occurring but getting wiped.

Second, the error will occur anyway, because your filter function tries to loop through a table the doesn't exist until your VARIABLES_LOADED handler fires, but you're using it to filter messages before that happens.
  Reply With Quote
01-17-10, 03:17 PM   #4
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
No other mods enabled during testing. Golden rule there mate.

That's assuming that chat begins before addons are even loaded, which I'm pretty sure isn't the case. I could be wrong though.
  Reply With Quote
01-17-10, 03:20 PM   #5
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Ah, I see. I missed this on the 3.0 API notes:

Until 3.0, VARIABLES_LOADED used to fire upon completion of the addon loading process; since 3.0, it is fired in response to CVars, Keybindings and other associated "Blizzard" variables being loaded, and may therefore be delayed until after PLAYER_ENTERING_WORLD. The event may still be useful to override positioning data stored in layout-cache.txt
So yes, you would be correct. I'll try moving it to ADDON_LOADED and see what happens.


EDIT: Nope, no dice. Even after hardcoding InIg = {} at the very beginning of the file, still coming up with the same error. And still no message given at "ADDON_LOADED".

EDIT: I set up a seperate saved var than just InIg, seems to be happy now. I've done it the other way before with no issues, but meh. Long as it works.

Last edited by Sythalin : 01-17-10 at 03:41 PM.
  Reply With Quote
01-17-10, 03:44 PM   #6
Starinnia
Ninja Code Monkey
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 84
This prolly isn't going to do anything, but did you try it without the parens around the table when you used the # operator?

Edit: Bah, missed your last edit....
  Reply With Quote
01-17-10, 05:01 PM   #7
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Originally Posted by ChaosInc View Post
EDIT: I set up a seperate saved var than just InIg, seems to be happy now. I've done it the other way before with no issues, but meh. Long as it works.
It might work if you didn't have any functions defined inside the frame as well, or if you defined them inside of your ADDON_LOADED handler, and only used references to the frame rather than a global name (which would get overridden when the saved vars loaded).
  Reply With Quote
01-20-10, 08:03 PM   #8
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Was working on APC today and started getting spammed with chat errors all of a sudden when it worked perfectly on it's last update. Cleared the WTF save files, downloaded my last working version and still getting spammed with errors.

Something has changed and now I'm kinda pissed because I have to go reconfigure half my projects because suddenly this is breaking EVERYTHING.




EDIT: Test further prove that events are being passed up (addon:EVENT() aren't firing), leading me to believe that there's something wrong with my "OnEvent" handler, but ****ed if I know what it is at this point, and I'm too pissed to concentrate on it atm.

Last edited by Sythalin : 01-20-10 at 08:07 PM.
  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