Thread Tools Display Modes
12-24-19, 09:38 AM   #1
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
[Retail] nPower not updated need help with error code.

Hello,
NeavUI has not been updated sence 08/27/18 some people have tried to do quick fixes but not everything is updated. One of the addons I use from it is called nPower and it works but keeps thowing me a error everytime a load screen comes up.

Here is the link to the GitHub for the addon to see the whole addon. nPower

the error code I am getting from BugGrabber is:
Code:
411x nPower\core.lua:209: attempt to perform arithmetic on local 'start' (a nil value)
nPower\core.lua:209: in function <nPower\core.lua:207>
nPower\core.lua:388: in function <nPower\core.lua:373>

Locals:
self = 1
start = nil
duration = nil
runeReady = nil
(*temporary) = <function> defined =[C]:-1
(*temporary) = 342594.828000
(*temporary) = 342594.828000
(*temporary) = nil
(*temporary) = "attempt to perform arithmetic on local 'start' (a nil value)"
It seems to only happen on my Deathknight. the chunk of code that is being referenced is:
Lua Code:
  1. local function CalcRuneCooldown(self)
  2.     local start, duration, runeReady = GetRuneCooldown(self)
  3.     local time = floor(GetTime() - start)
  4.     local cooldown = ceil(duration - time)
  5.  
  6.     if (runeReady or UnitIsDeadOrGhost("player")) then
  7.         return "#"
  8.     elseif (not UnitIsDeadOrGhost("player") and cooldown) then
  9.         return cooldown
  10.     end
  11. end

and this function only seems to show up in this bit of code at the end of the .lua:
Lua Code:
  1. if (f.Rune) then
  2.     local updateTimer = 0
  3.     f:SetScript("OnUpdate", function(self, elapsed)
  4.         updateTimer = updateTimer + elapsed
  5.  
  6.         if (updateTimer > 0.1) then
  7.             for i = 1, 6 do
  8.                 if (UnitHasVehicleUI("player")) then
  9.                     if (f.Rune[i]:IsShown()) then
  10.                         f.Rune[i]:Hide()
  11.                     end
  12.                 else
  13.                     if (not f.Rune[i]:IsShown()) then
  14.                         f.Rune[i]:Show()
  15.                     end
  16.                 end
  17.  
  18.                 f.Rune[i]:SetText(CalcRuneCooldown(i))
  19.                 f.Rune[i]:SetTextColor(0.0, 0.6, 0.8)
  20.             end
  21.  
  22.             updateTimer = 0
  23.         end
  24.     end)
  25. end

Hopefully one of you awesome programmers have an idea why this keep throwing an error.

Thanks in advance for any help solving this issue.

Coke
  Reply With Quote
12-24-19, 01:37 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
In my rune code I check that start has been given a value (Blizzard does also in their UpdateRunes function which probably means GetRuneCooldown can return nil for start no matter what the online docs say) so a change to something like:

Lua Code:
  1. local function CalcRuneCooldown(self)
  2.     local cooldown
  3.     local start, duration, runeReady = GetRuneCooldown(self)
  4.     if start then
  5.         local time = floor(GetTime() - start)
  6.         cooldown = ceil(duration - time)
  7.     end    
  8.     if (runeReady or UnitIsDeadOrGhost("player")) then
  9.         return "#"
  10.     elseif (not UnitIsDeadOrGhost("player") and cooldown) then
  11.         return cooldown
  12.     end
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 12-24-19 at 07:50 PM.
  Reply With Quote
12-24-19, 03:38 PM   #3
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Here's what i'm using and built around nPower code.

Lua Code:
  1. local A, C, L = select(2, ...):unpack()
  2. local RuneBar = CreateFrame("Frame")
  3. local DataBars = A["DataBars"]
  4. local Panels = A["Panels"]
  5.  
  6. -- Lib Globals
  7. local select = select
  8. local unpack = unpack
  9.  
  10. -- WoW Globals
  11. local GetRuneCooldown = GetRuneCooldown
  12. local GetTime = GetTime
  13. local UnitClass = UnitClass
  14. local GetSpecialization = GetSpecialization
  15.  
  16. -- Locals
  17. local Class = select(2, UnitClass("player"))
  18.  
  19. -- Color Tabels
  20. local Mult = 2.5
  21. local BloodColor = { 1 * Mult, 0, 0 }
  22. local FrostColor = { 0, 0.35 * Mult, 1 * Mult }
  23. local UnholyColor = { 0.25 * Mult, 0.55 * Mult, 0.10 * Mult }
  24.  
  25. function RuneBar:OnUpdate(Elapsed)
  26.     local Duration = self.Duration + Elapsed
  27.     self.Duration = Duration
  28.     self:SetValue(Duration)
  29. end
  30.  
  31. function RuneBar:Update()
  32.     for i = 1, 6 do
  33.         local Start, Duration, RuneIsReady = GetRuneCooldown(i)
  34.         if (Start) then        
  35.             self.RunesBars[i].Duration = GetTime() - Start
  36.             self.RunesBars[i]:SetMinMaxValues(0, Duration)
  37.             self.RunesBars[i]:SetScript("OnUpdate", self.OnUpdate)
  38.         else
  39.             self.RunesBars[i]:SetMinMaxValues(0, 1)
  40.             self.RunesBars[i]:SetValue(1)
  41.             self.RunesBars[i]:SetScript("OnUpdate", nil)
  42.         end
  43.     end
  44. end
  45.  
  46. function RuneBar:UpdateSpec()  
  47.     for i = 1, 6 do
  48.         local GetSpecialization = GetSpecialization()
  49.         if (GetSpecialization == 1) then
  50.             self.RunesBars[i]:SetStatusBarColor(unpack(BloodColor))
  51.         elseif (GetSpecialization == 2) then
  52.             self.RunesBars[i]:SetStatusBarColor(unpack(FrostColor))
  53.         elseif (GetSpecialization == 3) then
  54.             self.RunesBars[i]:SetStatusBarColor(unpack(UnholyColor))
  55.         end
  56.     end
  57. end
  58.  
  59. function RuneBar:OnEvent(event)
  60.     if (event == "RUNE_POWER_UPDATE") then
  61.         self:Update()
  62.     elseif (event == "PLAYER_ENTERING_WORLD" or event == "PLAYER_SPECIALIZATION_CHANGED" or event == "PLAYER_TALENT_UPDATE") then
  63.         self:UpdateSpec()
  64.     end
  65. end
  66.  
  67. function RuneBar:CreateBar()
  68.     local Bar = CreateFrame("StatusBar", nil, UIParent)
  69.     Bar:Size(220, 12)
  70.     Bar:Point("TOP", Panels.ActionBarPanelMiddle, 0, 32)
  71.    
  72.     local RunesBars = {}
  73.  
  74.     for i = 1, 6 do
  75.         local Bars = CreateFrame("StatusBar", nil, Bar)
  76.         Bars:Size(210/6, 12)
  77.         Bars:SetStatusBarTexture(C.Media.Texture)
  78.         Bars:CreateBackdrop()
  79.         Bars:CreateShadow()
  80.        
  81.         if (i == 1) then
  82.             Bars:Point("LEFT", Bar, 2, 0)
  83.         else
  84.             Bars:Point("LEFT", RunesBars[i-1], "RIGHT", 2, 0)
  85.         end
  86.        
  87.         RunesBars[i] = Bars
  88.     end
  89.    
  90.     RegisterStateDriver(Bar, "visibility", "[vehicleui][petbattle] hide; show")
  91.  
  92.     self:RegisterEvent("RUNE_POWER_UPDATE")
  93.     self:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED")
  94.     self:RegisterEvent("PLAYER_TALENT_UPDATE")
  95.     self:RegisterEvent("PLAYER_REGEN_ENABLED")
  96.     self:RegisterEvent("PLAYER_REGEN_DISABLED")
  97.     self:RegisterEvent("PLAYER_ENTERING_WORLD")
  98.     self:SetScript("OnEvent", self.OnEvent)
  99.    
  100.     self.Bar = Bar
  101.     self.RunesBars = RunesBars
  102. end
  103.  
  104. function RuneBar:Enable()
  105.     if not (C.DataBars.RuneBar) or (Class ~= "DEATHKNIGHT") then
  106.         return
  107.     end
  108.  
  109.     self:CreateBar()
  110. end
  111.  
  112. DataBars.RuneBar = RuneBar
  Reply With Quote
12-25-19, 08:24 AM   #4
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by Fizzlemizz View Post
In my rune code I check that start has been given a value (Blizzard does also in their UpdateRunes function which probably means GetRuneCooldown can return nil for start no matter what the online docs say) so a change to something like:

Lua Code:
  1. local function CalcRuneCooldown(self)
  2.     local cooldown
  3.     local start, duration, runeReady = GetRuneCooldown(self)
  4.     if start then
  5.         local time = floor(GetTime() - start)
  6.         cooldown = ceil(duration - time)
  7.     end    
  8.     if (runeReady or UnitIsDeadOrGhost("player")) then
  9.         return "#"
  10.     elseif (not UnitIsDeadOrGhost("player") and cooldown) then
  11.         return cooldown
  12.     end
Thank You @Fizzlemizz it works perfectly, it so nice not hearing the "fatality" every time the screen loads.
  Reply With Quote
12-25-19, 12:00 PM   #5
JDoubleU00
A Firelord
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 463
Originally Posted by cokedrivers View Post
Thank You @Fizzlemizz it works perfectly, it so nice not hearing the "fatality" every time the screen loads.
"fatality" is what that Gnome voice says? I've wondered for years what that was, but was too lazy to figure it out.
__________________
Author of JWExpBar and JWRepBar.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » [Retail] nPower not updated need help with error code.

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