Originally Posted by
diesall
yes quite a bit faster, localizing PQ_HandleEvents will result in even more performance.
Are local variables works in some different way in lua then in other languages? :/
So this is right way? :
Code:
if not PQ_EventHandlerLoaded then
local PQ_EventHandlerFrame, events = CreateFrame("Frame"), {};
local function events:COMBAT_LOG_EVENT_UNFILTERED(...)
end
local function events:PLAYER_REGEN_DISABLED(...)
end
local function events:PLAYER_REGEN_ENABLED(...)
end
local function events:PLAYER_CONTROL_LOST(...)
end
local function events:PLAYER_CONTROL_GAINED(...)
end
local function events:MODIFIER_STATE_CHANGED(...)
end
local function events:UNIT_POWER(...)
end
local function events:PLAYER_TARGET_CHANGED(...)
end
local function events:PLAYER_FOCUS_CHANGED(...)
end
local function events:UPDATE_MOUSEOVER_UNIT(...)
end
local function events:INSTANCE_ENCOUNTER_ENGAGE_UNIT(...)
end
local function events:UNIT_SPELLCAST_START(...)
end
local function events:UNIT_SPELLCAST_SUCCEEDED(...)
end
local function events:RAID_ROSTER_UPDATE(...)
end
local function events:ACTIVE_TALENT_GROUP_CHANGED(...)
end
local function PQ_Init()
end
--Notify frame
PQ_NotifyFrame = CreateFrame('Frame')
PQ_NotifyFrame:ClearAllPoints()
PQ_NotifyFrame:SetHeight(300)
PQ_NotifyFrame:SetWidth(300)
PQ_NotifyFrame:SetScript('OnUpdate', PQ_NotifyFrame_OnUpdate)
PQ_NotifyFrame:Hide()
PQ_NotifyFrame.text = PQ_NotifyFrame:CreateFontString(nil, 'BACKGROUND', 'PVPInfoTextFont')
PQ_NotifyFrame.text:SetAllPoints()
PQ_NotifyFrame:SetPoint('CENTER', 0, 200)
PQ_NotifyFrameTime = 0
local function PQ_HandleEvents(self, event, ...)
end
PQ_EventHandlerFrame:SetScript("OnEvent", PQ_HandleEvents(self, event, ...));
for k, v in pairs(events) do
PQ_EventHandlerFrame:RegisterEvent(k); -- Register all events for which handlers have been defined
end
PQ_Init()
PQ_EventHandlerLoaded = true
if PQ_EventHandlerLoaded then
if PQ_Debug then
DebugFrame.messageFrame:AddMessage('Sucess!!!')
end
else
if PQ_Debug then
DebugFrame.messageFrame:AddMessage('FAIL!!!')
end
end
end