mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-24 08:36:04 +00:00
thirdparty: move addon hook function to api
This commit is contained in:
+18
@@ -323,6 +323,24 @@ function pfUI.api.HookScript(f, script, func)
|
||||
end)
|
||||
end
|
||||
|
||||
-- [ HookAddonOrVariable ]
|
||||
-- Sets a function to be called automatically once an addon gets loaded
|
||||
-- 'addon' [string] addon or variable name
|
||||
-- 'func' [function] function that should run
|
||||
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()
|
||||
if IsAddOnLoaded(addon) or _G[addon] then
|
||||
this:func()
|
||||
this:UnregisterAllEvents()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- [ QueueFunction ]
|
||||
-- Add functions to a FIFO queue for execution after a short delay.
|
||||
-- '...' [vararg] function, [arguments]
|
||||
|
||||
Reference in New Issue
Block a user