diff --git a/api/api.lua b/api/api.lua index 376893cb..fa8a556c 100644 --- a/api/api.lua +++ b/api/api.lua @@ -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()