Thread Tools Display Modes
01-04-18, 10:25 AM   #1
gempir
A Black Drake
 
gempir's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2015
Posts: 84
oUF Aurawatch custom bars

Hey,

I'm trying to create simple aura bars that show the length of buffs. Currently I have this


I'm using oUF and oUF AuraWatch (http://www.wowinterface.com/download...AuraWatch.html) for this

I'm unsure how I could create aura bars now instead of these cooldown icons, because AuraWatch seems to be designed for icons.

This is my current setup for AuraWatch, any ideas how to create a statusbar from that?
Lua Code:
  1. local auras = {}
  2.        
  3.     auras.presentAlpha = 1
  4.     auras.missingAlpha = 0
  5.     auras.PostCreateIcon = AWIcon
  6.     -- Set any other AuraWatch settings
  7.     auras.icons = {}
  8.     if G.aurawatch.spellIDs[class] then
  9.         for i, sid in pairs(G.aurawatch.spellIDs[class]) do
  10.             local icon = CreateFrame("Frame", nil, self)
  11.             icon.spellID = sid
  12.             -- set the dimensions and positions
  13.             icon:SetWidth(48)
  14.             icon:SetHeight(48)
  15.             icon:SetPoint("BOTTOMLEFT", self, "TOPLEFT", -52 + (i * 52), 42)
  16.             auras.icons[sid] = icon
  17.             -- Set any other AuraWatch icon settings
  18.         end
  19.     end
  20.     self.AuraWatch = auras
  Reply With Quote
01-06-18, 10:19 AM   #2
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
The 6th and 7th return of UnitAura are duration (in seconds) and expiration (the moment in time when the aura will expire). For every aura you want to track, you create a statusbar widget and set its properties like so:

lua Code:
  1. bar:SetMinMaxValues(0, duration)
  2. bar.timeLeft = expiration - GetTime()
  3. bar:SetScript('OnUpdate', UpdateTimer)
  4. bar:Show()

The UpdateTimer function should look something like that:
lua Code:
  1. local function UpdateTimer(bar, elapsed)
  2.     local timeLeft = bar.timeLeft - elapsed
  3.     if(timeLeft > 0) then
  4.         bar:SetValue(timeLeft)
  5.         bar.timeLeft = timeLeft
  6.     else
  7.         bar:Hide()
  8.     end
  9. end

Edit: remember to re-use your statusbars. Create new ones only if needed.

Last edited by Rainrider : 01-06-18 at 10:24 AM.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » oUF Aurawatch custom bars

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