View Single Post
08-10-14, 09:13 AM   #1
ObbleYeah
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 210
casting bar: attempt to perform arithmetic

Code:
\castbar.lua:77: attempt to perform arithmetic on local "endTime" (a nil value)
happens when i'm casting and my target is channeling simultaneously.

Lua Code:
  1. --
  2.  
  3. -- latency ------------------------------------------------------------------------------
  4.  
  5.     local function findCastLatency(self)
  6.         local latency = self.latency
  7.         local width = self:GetWidth()
  8.         local _, _, _, ms = GetNetStats()
  9.  
  10.         if (ms~=0) then
  11.             local safeZonePercent = (width/self.max) * (ms/1e5)
  12.             if(safeZonePercent > 1) then
  13.                 safeZonePercent = 1
  14.             end
  15.             latency:SetWidth(width*safeZonePercent)
  16.             latency:Show()
  17.         else
  18.             latency:Hide()
  19.         end
  20.     end
  21.  
  22.     local function cbLatency(self, event, ...)  
  23.         local name, _, text, texture, startTime, endTime, castid, interrupt        
  24.         local unit, spellName, _, id, spellId = ...
  25.         local cb = self.latency    
  26.        
  27.         -- we don't want to look at any castbars but our own
  28.         if (self.unit~="player") then return end
  29.    
  30.         if (event=="UNIT_SPELLCAST_START") then
  31.             if (cb) then
  32.                 name, _, text, texture, startTime, endTime, _, castid, interrupt = UnitCastingInfo(self.unit)
  33.                 endTime = endTime / 1e3
  34.                 startTime = startTime / 1e3
  35.                 local max = endTime - startTime
  36.                 self.max = max
  37.                 cb:ClearAllPoints()
  38.                 cb:SetPoint("TOP")
  39.                 cb:SetPoint("BOTTOM")
  40.                 cb:SetPoint("RIGHT")
  41.             end            
  42.             findCastLatency(self)
  43.         elseif (event=="UNIT_SPELLCAST_CHANNEL_START") then
  44.             if (cb) then
  45.                 name, _, text, texture, startTime, endTime, _, castid, interrupt = UnitChannelInfo(self.unit)
  46.                 endTime = endTime / 1e3
  47.                 startTime = startTime / 1e3
  48.                 local max = endTime - startTime
  49.                 self.max = max
  50.                 self.casting = nil
  51.                 self.castid = nil
  52.                 cb:ClearAllPoints()
  53.                 cb:SetPoint("TOP")
  54.                 cb:SetPoint("BOTTOM")
  55.                 cb:SetPoint("LEFT")
  56.             end            
  57.             findCastLatency(self)
  58.         elseif ((event=="UNIT_SPELLCAST_STOP") or (event=="UNIT_SPELLCAST_CHANNEL_STOP") or  (event=="UNIT_SPELLCAST_FAILED") or (event=="UNIT_SPELLCAST_INTERRUPTED")) then
  59.             if (not self.casting and not self.channeling) then
  60.                 cb:Hide()
  61.                 self.queuezone:Hide()
  62.             end
  63.         end
  64.     end
  65.      
  66.     hooksecurefunc("CastingBarFrame_OnEvent", cbLatency)

line 77 is the UnitChannelInfo endTime. What's causing this?

Last edited by ObbleYeah : 08-10-14 at 09:15 AM.
  Reply With Quote