Thread Tools Display Modes
05-16-13, 08:01 PM   #1
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
Responsiveness of Health and Power Tags

Good evening,

Today's raid was re-scheduled, so I decided to use some of my time to work on a few AddOns. Specifically, I was concerned with the responsiveness of my oUF layout's health and power tags. I use a frequentUpdates value of 0.1, and I was still noticing a significant delay between health or power changing, and the tag reflecting that.

To make sure that I wasn't improperly setting the frequentUpdates value, I went into tags.lua and FORCED the timer to be 0.1, and later 0.001, only to see no change.

I decided to try to add UNIT_HEALTH_FREQUENT and UNIT_POWER_FREQUENT to the tags that I was using, and voila, they were updating as fast as ever.
(This was more or less an epiphany as I was reading through tags.lua)

If the health and power tags may only depend on the slower UNIT_HEALTH, and UNIT_POWER tags, then no matter how quickly the OnUpdate function runs, it will still have to wait for that new information to reflect it.

Not sure if this is helpful at all for the developers, but it gave me the desired result.

Last edited by Clamsoda : 05-16-13 at 08:11 PM.
  Reply With Quote
05-17-13, 06:52 AM   #2
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
There are units that events are not fired for: maintank, mainassist and everything with a target suffix. And there are unitless events. In that case oUF uses a standard 0.5 update frequency or whatever value you provided by setting frequentUpdates on the font object that holds the corresponding tag. For other units it only updates the tag when the event fires for the corresponding unit.

Edit: Hm, I just read through the code and you are right, the presence of frequentUpdates should add the tag update to the unitless list. So my guess is you are setting frequentUpdates in the wrong place.

Last edited by Rainrider : 05-17-13 at 07:06 AM.
  Reply With Quote
05-17-13, 05:50 PM   #3
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
Hello Rainrider, thank you for the reply.

I imagine I was a bit confused. frequentUpdates ONLY pertains to text tags that don't have an associated event? I was under the assumption that all tags obeyed an OnUpdate loop that polled the information.

Also, I am pretty certain I am defining frequentUpdates for my font objects adequately; I think the issue lied within the events registered. Even with a frequentUpdates value of 0.1, if my health tag is responding to an event that fires every half of a second, nothing will change.

I was able to register UNIT_FREQUENT_HEALTH and UNIT_FREQUENT_POWER to the relevant tags to achieve the responsiveness I was looking for.

Lua Code:
  1. --------------------------------
  2. -- oUF Tag Event Registration --
  3. --------------------------------
  4.     oUF.Tags.Events["curhp"] = "UNIT_HEALTH_FREQUENT"
  5.     oUF.Tags.Events["maxhp"] = "UNIT_HEALTH_FREQUENT"
  6.     oUF.Tags.Events["perhp"] = "UNIT_HEALTH_FREQUENT"
  7.  
  8.     oUF.Tags.Events["curpp"] = "UNIT_POWER_FREQUENT"
  9.     oUF.Tags.Events["maxpp"] = "UNIT_POWER_FREQUENT"
  10.     oUF.Tags.Events["perpp"] = "UNIT_POWER_FREQUENT"

I am still interested in what role, if any, frequentUpdates plays for text tags that depend on an event.
  Reply With Quote
05-17-13, 09:50 PM   #4
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
oUF checks if the unit you registered the tag for has a target suffix (focustarget, pettarget, targettarget and so on - maintank and mainassist are not checked against, I was wrong about it in my previous post, sorry for that) or whether a frequentUpdates field is set on the font object for the tag or . If any of this conditions are met, oUF looks if frequentUpdates resolves to a number and, if so, it uses this number as the update timer or a default value of 0.5 else (meaning update twice a second).

Let's test what you describe.
1. Create the health tag function:
lua Code:
  1. oUF.Tags.Methods["layoutName:healthTag"] = function(unit)
  2.     print(date("%X"), "healthTag", unit) -- we use this for debug
  3.     if (not UnitIsConnected(unit) or UnitIsDeadOrGhost(unit)) then return end
  4.     return UnitHealth(unit)
  5. end
  6. oUF.Tags.Events["layoutName:healthTag"] = "UNIT_HEALTH UNIT_MAXHEALTH"

2. Create the font object and add the tag to it:
Lua Code:
  1. local healthValue = self.Health:CreateFontString(nil, "OVERLAY")
  2. healthValue:SetFont(fontName, fontHeight, fontStyle)
  3. healthValue:SetPoint("TOPRIGHT", self.Health, -3.5, -3.5)
  4. healthValue.frequentUpdates = 2 -- this means update every 2 seconds
  5. self:Tag(healthValue, "[layoutName:healthTag]")
  6. self.Health.value = healthValue

3. Make sure you set the above for the player frame

The client gets UNIT_HEALTH only if there is a change in the unit's health. So, without using frequentUpdates we would get the output of our print in the health tag only when we loose or gain health. If we are at full health, we shoud see the print only when oUF refreshes the unit (vehicle enter/exit, PLAYER_ENTERING_WORLD ...). If we use frequentUpdates as defined above, we should see the print every 2 seconds, regardless of whether a change in health occurred (date("%X") will let you verify that, as long as the update timer is not a fraction of a second).

The bottom line is, UNIT_HEALTH_FREQUENT is better than using frequentUpdates, as you get the event only when a change in health occurs. With frequentUpdates you will call UnitHealth(unit) from within your health tag function a lot of times to get maybe redundant information. UNIT_HEALTH_FREQUENT fires about 10 times as often as UNIT_HEALTH (that may have changed since the last time I checked).
  Reply With Quote
05-17-13, 10:12 PM   #5
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Originally Posted by Rainrider View Post
UNIT_HEALTH_FREQUENT fires about 10 times as often as UNIT_HEALTH (that may have changed since the last time I checked).
UHF fires on change, UH fires on set times.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Responsiveness of Health and Power Tags


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