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:
--
-- latency ------------------------------------------------------------------------------
local function findCastLatency(self)
local latency = self.latency
local width = self:GetWidth()
local _, _, _, ms = GetNetStats()
if (ms~=0) then
local safeZonePercent = (width/self.max) * (ms/1e5)
if(safeZonePercent > 1) then
safeZonePercent = 1
end
latency:SetWidth(width*safeZonePercent)
latency:Show()
else
latency:Hide()
end
end
local function cbLatency(self, event, ...)
local name, _, text, texture, startTime, endTime, castid, interrupt
local unit, spellName, _, id, spellId = ...
local cb = self.latency
-- we don't want to look at any castbars but our own
if (self.unit~="player") then return end
if (event=="UNIT_SPELLCAST_START") then
if (cb) then
name, _, text, texture, startTime, endTime, _, castid, interrupt = UnitCastingInfo(self.unit)
endTime = endTime / 1e3
startTime = startTime / 1e3
local max = endTime - startTime
self.max = max
cb:ClearAllPoints()
cb:SetPoint("TOP")
cb:SetPoint("BOTTOM")
cb:SetPoint("RIGHT")
end
findCastLatency(self)
elseif (event=="UNIT_SPELLCAST_CHANNEL_START") then
if (cb) then
name, _, text, texture, startTime, endTime, _, castid, interrupt = UnitChannelInfo(self.unit)
endTime = endTime / 1e3
startTime = startTime / 1e3
local max = endTime - startTime
self.max = max
self.casting = nil
self.castid = nil
cb:ClearAllPoints()
cb:SetPoint("TOP")
cb:SetPoint("BOTTOM")
cb:SetPoint("LEFT")
end
findCastLatency(self)
elseif ((event=="UNIT_SPELLCAST_STOP") or (event=="UNIT_SPELLCAST_CHANNEL_STOP") or (event=="UNIT_SPELLCAST_FAILED") or (event=="UNIT_SPELLCAST_INTERRUPTED")) then
if (not self.casting and not self.channeling) then
cb:Hide()
self.queuezone:Hide()
end
end
end
hooksecurefunc("CastingBarFrame_OnEvent", cbLatency)
line 77 is the UnitChannelInfo endTime. What's causing this?