Thread Tools Display Modes
12-04-10, 08:50 AM   #1
drakull
A Cyclonian
 
drakull's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 49
Dynamically changing frame position

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:
  1. -- the function:
  2. lib.updatePetFrame = function(self, event, unit) -- unit is always nil here :(
  3.     local anchor = oUF_drkPlayer
  4.     if event == "PET_ATTACK_START" then
  5.         anchor = oUF_drkPettarget
  6.     elseif event == "PLAYER_FOCUS_CHANGED" then
  7.         if (UnitExits("focus")) then anchor = oUF_drkFocus end
  8.     end
  9.     self:SetPoint("BOTTOMLEFT", anchor,"TOPLEFT", 0, 8)
  10. end
  11.  
  12. -- and inside pet style func:
  13. self:RegisterEvent('PLAYER_FOCUS_CHANGED', lib.updatePetFrame)
  14. self:RegisterEvent('PET_ATTACK_START', lib.updatePetFrame)
  15. 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".
  Reply With Quote
12-04-10, 09:02 AM   #2
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
You can only move secure frames (all oUF frames) and frames with secure children out of combat. In other words, you can't really do this.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
12-04-10, 09:21 AM   #3
drakull
A Cyclonian
 
drakull's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 49
Ty, haste!

Oh, snap... and there goes my great idea.

Edit: Anyways, i got curious. Is there a way to determine if a unit is visible, ie: to know if the player has or not set a focus?

Last edited by drakull : 12-04-10 at 09:27 AM.
  Reply With Quote
12-04-10, 01:05 PM   #4
Rostok
A Flamescale Wyrmkin
Join Date: Jul 2008
Posts: 127
UnitExists("focus") maybe.
  Reply With Quote
12-04-10, 02:34 PM   #5
drakull
A Cyclonian
 
drakull's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 49
Yeah, it's UnitExists(), Just noted the typo on the code i posted above...
/facepalm
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Dynamically changing frame position


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off