-
Posted by voyager69 on Tue, 05 Apr 2011 19:03:22
Why o why does the following code dont do what the API is telling it should do? Probably a coding-error or something else? ... (maybe not the right API? or registering the right event?)
local a = CreateFrame("Frame") a:SetScript("OnEvent", function(self, event, ...) self.pguid = self.pguid or UnitGUID("player") local arg = {...} if arg[2] == "SPELL_INTERRUPT" and arg[10] == "Mind Freeze" and arg[3]==self.pguid then SendChatMessage("I interupted with Mind Freeze: "..GetSpellLink(arg[12]), "YELL") end end) a:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
Can anyone tell what is wrong in the code? And also .. how can i write this code more in the style of the book?
Btw I get the below error-message, maybe it helps:
Message: Interface\AddOns\SayMindFreeze\SayMindFreeze.lua:6 : GetSpellLink(): Invalid spell slot Time: 04/05/11 17:53:53 Count: 1 Stack: [C]: in function `GetSpellLink' Interface\AddOns\SayMindFreeze\SayMindFreeze.lua:6 : in function <Interface\AddOns\SayMindFreeze\SayMindFreeze.lua: 2> Locals: (*temporary) = nil
In addition: I was told to check stuff if standard blizzard addons do what i need, but how can i check the combatlog? I see a directory combatlog in my addon directory, but i cant open it. The Combatlog does exactly show the line that i need and that i want yelled so my teammembers see whats happening: MyChar, mytarget, i succesfully used Mind Freeze on Goul of Flame (both spells with a hyperlink -- thats why i use getspelllink)
Kind regards, Voyager69
PS it took some time, but i am getting used to posting better (format-wise)
-
Posted by jnwhiteh on Tue, 05 Apr 2011 21:52:01
Why o why does the following code dont do what the API is telling it should do? Probably a coding-error or something else? ... (maybe not the right API? or registering the right event?)
local a = CreateFrame("Frame") a:SetScript("OnEvent", function(self, event, ...) self.pguid = self.pguid or UnitGUID("player") local arg = {...} if arg[2] == "SPELL_INTERRUPT" and arg[10] == "Mind Freeze" and arg[3]==self.pguid then SendChatMessage("I interupted with Mind Freeze: "..GetSpellLink(arg[12]), "YELL") end end) a:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
Can anyone tell what is wrong in the code? And also .. how can i write this code more in the style of the book?
I can't tell you what's wrong with that code, because I don't know. You'll have to do some troubleshooting on your own. In particular you can use the /eventtrace function to find out precisely what each argument to the given event is and see why things might not work. It also might help to print out the values that you're checking and see what they are.
Btw I get the below error-message, maybe it helps:
Message: Interface\AddOns\SayMindFreeze\SayMindFreeze.lua:6 : GetSpellLink(): Invalid spell slot Time: 04/05/11 17:53:53 Count: 1 Stack: [C]: in function `GetSpellLink' Interface\AddOns\SayMindFreeze\SayMindFreeze.lua:6 : in function <Interface\AddOns\SayMindFreeze\SayMindFreeze.lua: 2> Locals: (*temporary) = nil
This should have been your first question. Never ever ignore error messages. Find out what they mean, and how to fix them. In this case, it is incredibly likely that arg[12] is nil, but I'm only guessing, as I'm not a psychic wow-running machine =)
In addition: I was told to check stuff if standard blizzard addons do what i need, but how can i check the combatlog? I see a directory combatlog in my addon directory, but i cant open it.
You extract the FrameXML code, as discussed in the book, or access one of the many resources that exist. You can view the code on Wowprogramming.com or Github, and I'm sure many others.
The Combatlog does exactly show the line that i need and that i want yelled so my teammembers see whats happening:
The combat log is just a dumb dump of data, it doesn't have any logic like this.
MyChar, mytarget, i succesfully used Mind Freeze on Goul of Flame (both spells with a hyperlink -- thats why i use getspelllink)
Kind regards, Voyager69
PS it took some time, but i am getting used to posting better (format-wise)
You can always use the 'Preview' button, it makes things much much easier =)