View Single Post
12-22-13, 08:28 PM   #1
Musca
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Nov 2013
Posts: 8
Aura string tag, how to use frequentUpdates ?

Hi all,

I'm trying to create a tag to show the pet's name. As I main a hunter, I would like it to show the remaining duration on Mend Pet if it's active, and go back to showing the pet name when it's not. Here is the code for the tag:

Code:
oUF.Tags.Methods['mu:petname'] = function(unit)
  local name = string.sub(UnitName(unit), 1, 5)
  local mendpet, _,_,_,_,_, expirationTime, source = UnitAura(unit, GetSpellInfo(136))
  if mendpet and source == 'player' then
    local t = floor(expirationTime - GetTime())
    return toHex(0.37, 0.81, 0.56) .. t .. '|r'
  elseif UnitIsDead(unit) then
    return toHex(0.6, 0.6, 0.6) .. '[RIP]|r'
  else
    return toHex(0.6, 0.6, 0.6) .. name .. '|r'
  end
end
oUF.Tags.Events['mu:petname'] = 'UNIT_AURA UNIT_NAME_UPDATE'
Now, I realise that this will only update the duration when the UNIT_AURA event fires, so it's not going to display the countdown in the way I want. So, borrowing from Quse (which hasn't been updated for a while but it's the only one I could find with aura strings), I used this code to create the name string on the pet frame:

Code:
  if pClass == 'HUNTER' then
    self:Tag(self.Name, '[mu:shortname]')
    self.Name.frequentUpdates = 0.25
  else
    other name tag
This ends up updating the string every few seconds, so I get '10' when I first cast Mend Pet, and then it might update again at '7', then again at '5', then at '2', and when it falls off it'll go back to showing the pet name.

I'm a bit flummoxed. How do I make it update more frequently than that ? I've tried changing the number, anything from 0.05 to 2, or just setting it to true, but it does not seem to make a difference to how quickly the string updates.

Sorry if this question is really noobish, this is my first go at trying to make a layout from scratch (and really first go at any programming at all)

Last edited by Musca : 12-22-13 at 08:37 PM.
  Reply With Quote