-
Posted by Drunk Cadaver on Thu, 14 Oct 2010 03:42:29
I have looked on Wowwiki, this site and UI/Macro forum and can't find a solution that works. Wowwiki shows on the "Patch 4.0.1/API changes" page that "Global variables this, event, arg1, ..., are no longer available." The following is the code I was using before the patch:
if not ad_frame then ad_frame = CreateFrame("Frame", "ad_frame") end ad_frame:RegisterEvent("UI_ERROR_MESSAGE") ad_frame:SetScript("OnEvent", function() if arg1 == "You are mounted." then Dismount() print("|cff24CDB1Auto Dismount dismounted you.") end end)
I've tried changing changing it to the following with no luck:
if not ad_frame then ad_frame = CreateFrame("Frame", "ad_frame") end ad_frame:RegisterEvent("UI_ERROR_MESSAGE") ad_frame:SetScript("OnEvent", function(self, event, ...) local arg1 = ... if arg1 == "You are mounted." then Dismount() print("|cff24CDB1Auto Dismount dismounted you.") end end)
I found this on the official forums but every time I try to use something from it (above for example), nothing seems to work.
local function MyEventHandler(self, event, ...) if (event == "SOME_EVENT") then local arg1, arg2 = ...; if (arg1 == "Blah" and arg2 > 0) then self:Hide() end end end
I don't know what to do to make it work. Is there somewhere you can point me to help me out or maybe a tip or two you could provide?
-
Posted by jnwhiteh on Thu, 14 Oct 2010 07:26:27
I can't speak to the specific event but frame and event registration is working the same as previously, i.e. the following works:
if not fooframe then fooframe = CreateFrame("Frame") end fooframe:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") fooframe:SetScript("OnEvent", function(self, event, ...) print(self, event, ...) end)
-
Posted by Drunk Cadaver on Thu, 14 Oct 2010 13:33:56
So for testing purposes I should try to remove Dismount() and use print(self, event, ...) to see what information shows up? That printed information may show me where I should go from there?
-
Posted by jnwhiteh on Thu, 14 Oct 2010 13:36:06
Yeah, it's a real good place to start =)
-
Posted by Drunk Cadaver on Thu, 14 Oct 2010 13:43:59
Never thought of that. Thanks for the direction and speedy reply. :)
-
Posted by Drunk Cadaver on Thu, 14 Oct 2010 20:06:21
if not ad_frame then ad_frame = CreateFrame("Frame", "ad_frame") end ad_frame:RegisterEvent("UI_ERROR_MESSAGE") ad_frame:SetScript("OnEvent", function(self, event, ...) local msg = ...
and then working with msg functions properly. Thanks again for pointing me in the right direction. I wish I would have thought of using print yesterday when I was pulling my hair out. :P