Thread: oUF_AuraBars
View Single Post
09-18-12, 12:30 AM   #11
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
In your last example:
Code:
local buff = buffs[i] 
bar.aura = aura --BuffBars.bars[i].aura
would set "bar.aura" to nil, because "aura" isn't defined. I think you meant "bar.aura = buff" there.

In your current file, line 305:
Code:
local bar = bars[i] --unecessary?  se line 267 above
No, because line 267 is not in scope here. Local only exist inside the "if/for/do/function ... end" block where they are defined with the "local something" declaration. The entire file counts as one big "do ... end" block for the purpose of scoping, but each block inside the file gets its own scope, and they nest like those Russian dolls. Each scope can only "see" variables declared in itself, or in a higher scope that contains itself. Line 267 and line 305 are in parallel scopes of equal depth; neither can "see" any variables defined inside the other.

Edit:

Alright, I just ended up rewriting the whole thing. Tested (as far as the BuffBars element with 2 buffs on a level 12 warlock) and working:

http://www.wowace.com/paste/6263/

Example and options in the comment header at the top of the file.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 09-18-12 at 04:26 AM.
  Reply With Quote