Thread: oUF_AuraBars
View Single Post
09-17-12, 10:45 AM   #8
sirann
A Flamescale Wyrmkin
Join Date: Mar 2007
Posts: 142
So if I'm understanding this correctly, we make a table for buffs with: local buffs = {}

We then make a function, for simplicity sake we'll just stick with the buffs. The function is called UpdateBuffs. It only updates when an event fires, which we register with self:RegisterEvent('UNIT_AURA', UpdateBuff). This function is also unit bound, so there can be target buffs, player buffs, focus buff, insert x frame category buffs all shown independently, and they all update independently. IE, when the player gains a buff, it doesn't cause the target buff UpdateBuff function to fire, thus unnecessarily increasing cpu load. Additionally it's set to fire only for HELPFUL aura changes. So it won't update when the unit gains or loses a debuff.

Next we set a variable, numBuffs to 0. We then set up our index to start at unit buff 1 get all the information from the UnitBuff api at that position, and store them in local variables set up. It continues to check each buff until it doesn't receive a name back (aka out of buffs to check) and breaks.

We create a local t and set it to the individual index of our buffs table created earlier (IE buffs[numBuffs]) so why don't we just use buffs[i] since whatever buff data we just got will be buff number i?

We then set up an if statement,
Lua Code:
  1. if not t then
  2.      t = table_create()
  3.      buffs[numBuffs] = t
  4. end

I don't fully understand this, we're checking to see if we have t, or anything in our buffs table. If we don't we create a table?

We then set buffs[i].locals to the locals that were set with the UnitBuff api.

We now set up a new for statement

Lua Code:
  1. for i = #buffs, numBuffs + 1, -1 do
  2.      buffs[i] = table_delete(buffs[i])
  3. end

so basically we start with the number of buffs in our buffs table and go to the total number of buffs found with numBuffs (isn't that the same as #buffs), and then continue till i = -1? I don't understand the 3 part for loop I guess.

We then sort the buffs using either the BuffsBars.sort function or default_sort.

Now we make a for loop starting at 1 and going until we run out of buffs. The loop makes a bar for each buff and breaks if the width of the bars is set to 0. We create and set a local bar = to bars[i] which is essentially BuffBars.bars[i].

If it discovers there's no bar made yet, it makes it, and decreases the i by one to redo the loop for that buff. We then show the bar.

We create a local statusBar and set it to bar.statusBar which is essentially bars[i].statusBar which is BuffBars.bars[i].statusBar.

We also create a local buff and set it to the individual i in our buffs table.

Now we set bar.aura = buff. This I don't understand, we say that BuffBars.bars[i].aura = buff or in other words BuffBars.bars[i].aura = buffs[i]. Where did .aura even come from? I think this may be where a lot of issue is coming from. I don't see the .aura set up anywhere else. I don't know, I'm pretty awful at coding so maybe I'm just misreading this
  Reply With Quote