mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-12 08:30:00 +00:00
api: run lurker on addon event if config exists
This commit is contained in:
@@ -340,9 +340,17 @@ end
|
|||||||
function pfUI.api.HookAddonOrVariable(addon, func)
|
function pfUI.api.HookAddonOrVariable(addon, func)
|
||||||
local lurker = CreateFrame("Frame", nil)
|
local lurker = CreateFrame("Frame", nil)
|
||||||
lurker.func = func
|
lurker.func = func
|
||||||
|
lurker:RegisterEvent("ADDON_LOADED")
|
||||||
lurker:RegisterEvent("VARIABLES_LOADED")
|
lurker:RegisterEvent("VARIABLES_LOADED")
|
||||||
lurker:RegisterEvent("PLAYER_ENTERING_WORLD")
|
lurker:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||||
lurker:SetScript("OnEvent",function()
|
lurker:SetScript("OnEvent",function()
|
||||||
|
-- only run when config is available
|
||||||
|
if event == "ADDON_LOADED" and not this.foundConfig then
|
||||||
|
return
|
||||||
|
elseif event == "VARIABLES_LOADED" then
|
||||||
|
this.foundConfig = true
|
||||||
|
end
|
||||||
|
|
||||||
if IsAddOnLoaded(addon) or _G[addon] then
|
if IsAddOnLoaded(addon) or _G[addon] then
|
||||||
this:func()
|
this:func()
|
||||||
this:UnregisterAllEvents()
|
this:UnregisterAllEvents()
|
||||||
|
|||||||
Reference in New Issue
Block a user