Originally Posted by sezz
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:
local f = CreateFrame("Frame"); local EventExists = function(event) if (pcall(function() f:RegisterEvent(event); end)) then f:UnregisterEvent(event); return true; end end print(EventExists("MEH")); 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:
local f=CreateFrame("Frame");
local function EventExists(event)
local exists=pcall(f.RegisterEvent,f,event);-- This is the same as calling f:RegisterEvent(event)
if exists then f:UnregisterEvent(event); end
return exists;
end
This calls
f:RegisterEvent() directly instead of needlessly wrapping it in a dynamic function.