WoWInterface (
-   Lua/XML Help (
-   -   Addon creating SoulShard Bar (

Galaxy119 07-29-16 03:22 PM

Addon creating SoulShard Bar
I had an addon creating a SoulShard bar fro Afflic locks pre-7.0

I have updated it so that is shows and (seems) to work without issue for all Lock specs, however.. I get this error:

Message: ...terface\AddOns\oUF_Diablo\modules\oUF_SoulShards.lua:49: attempt to index local 'orb' (a nil value)
Time: 07/29/16 14:12:44
Count: 3
Stack: ...terface\AddOns\oUF_Diablo\modules\oUF_SoulShards.lua:49: in function <...terface\AddOns\oUF_Diablo\modules\oUF_SoulShards.lua:11>
(tail call): ?
(tail call): ?
...terface\AddOns\oUF_Diablo\modules\oUF_SoulShards.lua:67: in function <...terface\AddOns\oUF_Diablo\modules\oUF_SoulShards.lua:57>
(tail call): ?

The function in which it refers to is:
Lua Code:
  1. local Update = function(self, event, unit, powerType)
  2.   local bar = self.SoulShardPowerBar
  3.   local cur = UnitPower(unit, SPELL_POWER_SOUL_SHARDS)
  4.   local max = UnitPowerMax(unit, SPELL_POWER_SOUL_SHARDS)
  5.   --[[ --do not hide the bar when the value is empty, keep it visible
  6.   if cur < 1 then
  7.     if bar:IsShown() then bar:Hide() end
  8.     return
  9.   else
  10.     if not bar:IsShown() then bar:Show() end
  11.   end
  12.   ]]
  13.   --adjust the width of the soulshard power frame
  14.   local w = 64*(max+1)
  15.   bar:SetWidth(w)
  16.   for i = 1, bar.maxOrbs do
  17.     local orb = self.SoulShards[i]
  18.     if i > max then
  19.        if orb:IsShown() then orb:Hide() end
  20.     else
  21.       if not orb:IsShown() then orb:Show() end
  22.     end
  23.   end
  24.   for i = 1, max do
  25.     local orb = self.SoulShards[i]
  26.     local full = cur/max
  27.     if(i <= cur) then
  28.       if full == 1 then
  29.         orb.fill:SetVertexColor(1,0,0)
  30.         orb.glow:SetVertexColor(1,0,0)
  31.       else
  32.         orb.fill:SetVertexColor(bar.color.r,bar.color.g,bar.color.b)
  33.         orb.glow:SetVertexColor(bar.color.r,bar.color.g,bar.color.b)
  34.       end
  35.       orb.fill:Show()
  36.       orb.glow:Show()
  37.       orb.highlight:Show()
  38.     else
  39.       orb.fill:Hide()
  40.       orb.glow:Hide()
  41.       orb.highlight:Hide()
  42.     end
  43.   end

Line 49 being the "orb.fill:Hide()" line in the else condition at the end. Commenting out that leads me to line 50, then 51.
Commenting all 3 of those out removes the error, however it breaks the addon.

With the lines commented out, the soul shards are added to the bar as they are built, but are not removed when consumed.
Not commented out, the soul shards are removed from the bar as expected, but I am spammed with this error countless times while in combat.

Since it's returning with an error, it is also affecting other aspects of the UI addon I have built this into, so leaving the lines and ignoring the errors is not really an option.

Hiketeia 07-29-16 11:10 PM

I'd guess that your "max" is bigger than you think it is and it is trying to handle an orb that is out of range.

Is there a reason one loop uses bar.maxOrbs and the other just max?

Galaxy119 07-29-16 11:45 PM


Originally Posted by Hiketeia (Post 317194)
I'd guess that your "max" is bigger than you think it is and it is trying to handle an orb that is out of range.

Is there a reason one loop uses bar.maxOrbs and the other just max?

There absolutely is NOT a reason and changing the second to bar.maxOrbs solved my issue.
Thanks for pointing that out, not sure how I missed it.

Hiketeia 07-30-16 09:40 PM

np. sometimes all it needs is a second pair of eyeballs. or a second single eyeball. or a screenreader with a second set of hears - don't mean to be mean to the eyeless.

Phanx 07-31-16 12:47 AM

One other point to mention is that soul shards are now handled natively in the ClassIcons element. There's not an official oUF update yet, but you can use lightspark's update until there is.

All times are GMT -6. The time now is 10:40 PM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI