View Single Post
10-10-18, 06:54 AM   #2
lightspark
A Rage Talon Dragon Guard
 
lightspark's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2012
Posts: 341
Give names to your bars.

Lua Code:
  1. local classPower = CreateFrame("Frame", nil, UIParent);
  2. classPower:SetWidth(256);
  3. classPower:SetHeight(36);
  4. classPower:SetPoint("CENTER");
  5.  
  6. for i = 1, 10 do
  7.     local bar = CreateFrame("StatusBar", "ClassPowerBar" .. i, classPower);
  8.     bar:SetSize(36, 36);
  9.  
  10.     if i == 1 then
  11.         bar:SetPoint("LEFT", classPower, "LEFT");
  12.     else
  13.         bar:SetPoint("LEFT", classPower[i - 1], "RIGHT", 3, 0);
  14.     end
  15.  
  16.     classPower[i] = bar;
  17. end
  18.  
  19. frame.ClassPower = classPower;

In general, names aren't mandatory, but sometimes, like in this particular case, /fstack is very very picky.

-- edit #1

When you're "nesting" one frame table inside another one like so: frame[1] = anotherFrame, you must give anotherFrame a proper name, it's only needed when you index w/ numbers, if you do something like this: frame["1"] = anotherFrame, you can leave anotherFrame nameless.

Once again, it only applies to "nesting" inside other frames. For example, doing something like this won't cause any issues:
Lua Code:
  1. local classPower = CreateFrame("Frame", nil, UIParent);
  2. classPower:SetWidth(256);
  3. classPower:SetHeight(36);
  4. classPower:SetPoint("CENTER");
  5.  
  6. local container = {};
  7.  
  8. for i = 1, 10 do
  9.     local bar = CreateFrame("StatusBar", nil, classPower);
  10.     bar:SetSize(36, 36);
  11.  
  12.     if i == 1 then
  13.         bar:SetPoint("CENTER");
  14.     else
  15.         bar:SetPoint("LEFT", container[i - 1], "RIGHT", 3, 0);
  16.     end
  17.  
  18.     container[i] = bar;
  19. end
  20.  
  21. frame.ClassPower = container;
__________________

Last edited by lightspark : 10-10-18 at 07:15 AM.
  Reply With Quote