mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-23 16:16:56 +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)
|
||||
local lurker = CreateFrame("Frame", nil)
|
||||
lurker.func = func
|
||||
lurker:RegisterEvent("ADDON_LOADED")
|
||||
lurker:RegisterEvent("VARIABLES_LOADED")
|
||||
lurker:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
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
|
||||
this:func()
|
||||
this:UnregisterAllEvents()
|
||||
|
||||
Reference in New Issue
Block a user