I want the Pet's frame to be repositioned everytime the player sets/clears focus and also when the pet has/hasn't a target. I hooked some events and tried to determine if there's a focus/pettarget with
UnitExists():
lua Code:
-- the function:
lib.updatePetFrame = function(self, event, unit) -- unit is always nil here :(
local anchor = oUF_drkPlayer
if event == "PET_ATTACK_START" then
anchor = oUF_drkPettarget
elseif event == "PLAYER_FOCUS_CHANGED" then
if (UnitExits("focus")) then anchor = oUF_drkFocus end
end
self:SetPoint("BOTTOMLEFT", anchor,"TOPLEFT", 0, 8)
end
-- and inside pet style func:
self:RegisterEvent('PLAYER_FOCUS_CHANGED', lib.updatePetFrame)
self:RegisterEvent('PET_ATTACK_START', lib.updatePetFrame)
self:RegisterEvent('PET_ATTACK_STOP', lib.updatePetFrame)
Problem is that it's not always working when the pet atack starts/stop (sometimes when the pet atack stops the pet frame's anchor does not changes back to the player frame) and is not working at all with the focus thing, i get an error stating that UnitExists is a nil value. Has it been removed? Is there another way to determine if an unitframe is visible?
Oh, and I remember seeing at least one time in chat window: "Interface action failed because of an AddOn".