Thread Tools Display Modes
Prev Previous Post   Next Post Next
11-19-20, 06:30 PM   #1
biokiwi
A Defias Bandit
Join Date: Nov 2020
Posts: 3
StarCursor nan(ind)

hi i used the addon StarCursor for some time now and wanted to debug it since it has some issues after the prepatch.

the bug happens sometimes after a loadingscreen and corrupts some calculationand turns a Number into nan(ind) (NotANumber) and freezes the cursor animation. no lua error

the line " print(tostring((-1)^.5)); " also triggers the bug but i dont understand how this NaN affects the other calculations

This would be a fix but i stil would not understand what happens:
if (speed<0 and speed>0) then speed=0; end

The code:

local x,y,speed = 0,0,0; -- cursor (SnowfallCursor by Dyan)
local CursorFrame = CreateFrame("Frame", "CursorFrame", UIParent);
CursorFrame:SetFrameStrata("TOOLTIP");
CursorFrame.texture = CursorFrame:CreateTexture();
CursorFrame.texture:SetTexture([[Interface\Cooldown\star4]]);
CursorFrame.texture:SetBlendMode("ADD");
CursorFrame.texture:SetAlpha(0.5);
CursorFrame:SetScript( "OnUpdate", function(frame,elapsed)
local dX = x;
local dY = y;
x, y = GetCursorPosition();
dX = x - dX;
dY = y - dY;
print(tostring((-1)^.5));
local weight = 2048 ^ -elapsed;
speed = math.min(weight * speed + (1 - weight) * math.sqrt(dX * dX + dY * dY) / elapsed, 1024);
print(speed);
local size = speed / 6 - 50;
if ( size > 0) then
local scale = UIParent:GetEffectiveScale();
CursorFrame.texture:SetHeight(size);
CursorFrame.texture:SetWidth(size);
CursorFrame.texture:SetPoint("CENTER", UIParent, "BOTTOMLEFT", (x + 0.5 * dX) / scale, (y + 0.5 * dY) / scale);
CursorFrame.texture:Show();
else
CursorFrame.texture:Hide();
end
end);
  Reply With Quote
 

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » StarCursor nan(ind)

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