View Single Post
09-19-17, 06:52 PM   #1
Lesteryoung
A Black Drake
Join Date: Aug 2015
Posts: 81
Errors in small coordinates addon. Would appreciate help.

Lua Code:
  1. local CoordText = WorldMapFrame.BorderFrame.TitleText
  2.  
  3. local totalElapsed = 0
  4. WorldMapDetailFrame:HookScript('OnUpdate', function(self, elapsed)
  5.     if(totalElapsed > 0.1) then
  6.         if(WorldMapScrollFrame:IsMouseOver()) then
  7.             local scale = self:GetEffectiveScale()
  8.             local centerX, centerY = self:GetCenter()
  9.             local width, height = self:GetSize()
  10.             local x, y = GetCursorPosition()
  11.  
  12.             x = ((x / scale) - (centerX - (width / 2))) / width
  13.             y = (centerY + (height / 2) - (y / scale)) / height
  14.  
  15.             CoordText:SetFormattedText('%.0f , %.0f', x * 100, y * 100)
  16.             CoordText:SetTextColor(0, 1, 0)
  17.         else
  18.             local x, y = GetPlayerMapPosition('player')
  19.             CoordText:SetFormattedText('%.0f , %.0f', x * 100, y * 100)
  20.             CoordText:SetTextColor(1, 1, 0)
  21.         end
  22.  
  23.         totalElapsed = 0
  24.     else
  25.         totalElapsed = totalElapsed + elapsed
  26.     end
  27. end)

Is throwing this error, repeatedly.

Code:
25x Tweaks\Coordinates.lua:19: attempt to perform arithmetic on local 'x' (a nil value)
Tweaks\Coordinates.lua:19: in function <Tweaks\Coordinates.lua:4>

Locals:
self = WorldMapDetailFrame {
 0 = <userdata>
}
elapsed = 0.015000000596046
x = nil
y = nil
(*temporary) = <function> defined =[C]:-1
(*temporary) = WorldMapFrameTitleText {
 0 = <userdata>
}
(*temporary) = "%.0f , %.0f"
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = nil
(*temporary) = "attempt to perform arithmetic on local 'x' (a nil value)"
totalElapsed = 0.11200000345707
CoordText = WorldMapFrameTitleText {
 0 = <userdata>
Any ideas as to why? It seems to happen inside instances.

Thanks.
  Reply With Quote