Thread Tools Display Modes
07-29-16, 03:22 PM   #1
Joker119
A Flamescale Wyrmkin
 
Joker119's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 113
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:
Code:
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.
  Reply With Quote
07-29-16, 11:10 PM   #2
Hiketeia
An Aku'mai Servant
 
Hiketeia's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 33
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?
  Reply With Quote
07-29-16, 11:45 PM   #3
Joker119
A Flamescale Wyrmkin
 
Joker119's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 113
Originally Posted by Hiketeia View Post
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.
  Reply With Quote
07-30-16, 09:40 PM   #4
Hiketeia
An Aku'mai Servant
 
Hiketeia's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 33
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.
  Reply With Quote
07-31-16, 12:47 AM   #5
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
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.
__________________
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.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Addon creating SoulShard Bar

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