Files
SuperCleveRoidMacros/Extensions/Mouseover/CT_RaidAssist.lua
T
Brues 9bebbbb836 Fix addon initialization order with guard checks
Refactor mouseover extensions to split initialization into two phases: OnLoad (empty) and OnAddOnLoad (actual setup). This ensures hooks are only registered when the target addon's globals are defined. Add guard clauses to check for required functions before hooking. Also remove Cursive's premature initialization attempt.
2026-07-27 14:32:12 -05:00

61 lines
1.5 KiB
Lua

--[[
Author: Dennis Werner Garske (DWG) / brian / Mewtiny
License: MIT License
]]
local _G = _G or getfenv(0)
local CleveRoids = _G.CleveRoids or {}
local Extension = CleveRoids.RegisterExtension("CT_RaidAssist")
function Extension.OnEnter()
local tempOptions = CT_RAMenu_Options["temp"]
if ( SpellIsTargeting() ) then
SetCursor("CAST_CURSOR")
end
local parent = this.frameParent
local id = parent.id
if ( strsub(parent.name, 1, 12) == "CT_RAMTGroup" ) then
local name
if ( CT_RA_MainTanks[id] ) then
name = CT_RA_MainTanks[id]
end
for i = 1, GetNumRaidMembers(), 1 do
local memberName = GetRaidRosterInfo(i)
if ( name == memberName ) then
id = i
break
end
end
elseif ( strsub(parent.name, 1, 12) == "CT_RAPTGroup" ) then
local name
if ( CT_RA_PTargets[id] ) then
name = CT_RA_PTargets[id]
end
for i = 1, GetNumRaidMembers(), 1 do
local memberName = GetRaidRosterInfo(i)
if ( name == memberName ) then
id = i
break
end
end
end
CleveRoids.SetMouseoverFrom("ctra", "raid"..id)
end
function Extension.OnLeave()
CleveRoids.ClearMouseoverFrom("ctra")
CleveRoids.ClearMouseoverFrom("native")
end
function Extension.OnLoad() end
function Extension.OnAddOnLoad()
if not CT_RA_MemberFrame_OnEnter then return end
Extension.Hook("CT_RA_MemberFrame_OnEnter", "OnEnter")
Extension.HookMethod(_G["GameTooltip"], "Hide", "OnLeave")
Extension.HookMethod(_G["GameTooltip"], "FadeOut", "OnLeave")
end
EventUtil.ContinueOnAddOnLoaded("CT_RaidAssist", Extension.OnAddOnLoad)