Thread Tools Display Modes
12-18-15, 09:33 AM   #1
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Target frames

Is it possible to update the targettarget, targettargettarget, forcustarget, pettarget unitframes, based on their proper unit events somehow? Or is there any proper way to handle them besides a throttled onupdate script?
  Reply With Quote
12-18-15, 10:03 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
Update what part exactly?

You have UNIT_HEALTH_FREQUENT and UNIT_POWER_FREQUENT events for health and mana updates.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
12-18-15, 10:10 AM   #3
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Fizzlemizz View Post
Update what part exactly?

You have UNIT_HEALTH_FREQUENT and UNIT_POWER_FREQUENT events for health and mana updates.
Yes, but not for the mentioned frames.
  Reply With Quote
12-18-15, 11:40 AM   #4
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
*target units do not have any associated events, your only option is OnUpdate.

However, try to stick with one OnUpdate per frame, don't do one per "element".
  Reply With Quote
12-18-15, 12:18 PM   #5
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
Code:
	pt = CreateFrame("Button", "MyPetTarget",UIParent,"SecureUnitButtonTemplate")
	pt.unit = "pettarget"
	pt:SetAttribute("unit", pt.unit)
	pt:RegisterUnitEvent("UNIT_HEALTH_FREQUENT", pt.unit, pt.unit)
	pt:SetScript("OnEvent", function(self, event, ...)
			print(..., self.unit, UnitHealth(self.unit))
		end)
Seems to workish even though it appears to be running the event on pet health. Adding the second pt.unit to RegisterUnitEvent just gives you more events.

Probably not the perfect solution which would leave OnUpdate.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 12-18-15 at 12:38 PM.
  Reply With Quote
12-18-15, 01:08 PM   #6
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Fizzlemizz View Post
Code:
	pt = CreateFrame("Button", "MyPetTarget",UIParent,"SecureUnitButtonTemplate")
	pt.unit = "pettarget"
	pt:SetAttribute("unit", pt.unit)
	pt:RegisterUnitEvent("UNIT_HEALTH_FREQUENT", pt.unit, pt.unit)
	pt:SetScript("OnEvent", function(self, event, ...)
			print(..., self.unit, UnitHealth(self.unit))
		end)
Seems to workish even though it appears to be running the event on pet health. Adding the second pt.unit to RegisterUnitEvent just gives you more events.

Probably not the perfect solution which would leave OnUpdate.
No, if you register an invalid unit for an event, it will get auto registered to the player by default.
That event script runs based on the player's "UNIT_HEALTH_FREQUENT".

Last edited by Resike : 12-18-15 at 01:18 PM.
  Reply With Quote
12-18-15, 01:42 PM   #7
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
No, if you register an invalid unit for an event, it will get auto registered to the player by default.
It appears it will use any primary unit requiring a health event ie. it doeas RegesterEvent("UNIT_HEALTH_FREQUENT").

I did say it probably wasn't perfect.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 12-18-15 at 01:45 PM.
  Reply With Quote
12-18-15, 03:38 PM   #8
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Originally Posted by Fizzlemizz View Post
It appears it will use any primary unit requiring a health event ie. it doeas RegesterEvent("UNIT_HEALTH_FREQUENT").

I did say it probably wasn't perfect.
You could be right, the real issue here those events won't update the targettarget frames properly it's just works as a crippled onupdate script.
  Reply With Quote
12-18-15, 08:03 PM   #9
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,323
After some digging through Blizzard code, namely TargetFrame.lua, it appears the default UI updates the TargetOfTarget frame with OnUpdate.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Target frames

Thread Tools
Display Modes

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