View Single Post
04-11-21, 06:48 PM   #11
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,313
Originally Posted by sezz View Post
did you try if it works without using acevent which itself uses callbackhandler and that's propably why it doesn's work as you expect it?

Lua Code:
  1. local f = CreateFrame("Frame");
  2.  
  3. local EventExists = function(event)
  4.     if (pcall(function() f:RegisterEvent(event); end)) then
  5.         f:UnregisterEvent(event);
  6.         return true;
  7.     end
  8. end
  9.  
  10. print(EventExists("MEH"));
  11. print(EventExists("PLAYER_LOGIN"));
If you check a lot of events, it'll create a new function each time. This'll work better.
Lua Code:
  1. local f=CreateFrame("Frame");
  2. local function EventExists(event)
  3.     local exists=pcall(f.RegisterEvent,f,event);--  This is the same as calling f:RegisterEvent(event)
  4.     if exists then f:UnregisterEvent(event); end
  5.     return exists;
  6. end
This calls f:RegisterEvent() directly instead of needlessly wrapping it in a dynamic function.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote