From 7e6c4ae56e633f67268d6812cc46852093c10f89 Mon Sep 17 00:00:00 2001 From: shagu Date: Sun, 8 Dec 2024 12:46:56 +0100 Subject: [PATCH] worldmap-coordinates: skip coords while map is in unknown state This is required to be compatible to the latest version of aero[1]. While using the addon, the `WorldMapButton` does not return a proper `:GetCenter()` for a short period of time. This leads to `mx` and `my` being nil and breaking the calculation. Now the coordinates will just be skipped as long as `mx` and `my` could not be determined via `:GetCenter()`. [1] https://github.com/gashole/Aero --- mods/worldmap-coordinates.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mods/worldmap-coordinates.lua b/mods/worldmap-coordinates.lua index d02af79..2190e70 100644 --- a/mods/worldmap-coordinates.lua +++ b/mods/worldmap-coordinates.lua @@ -45,8 +45,10 @@ module.enable = function(self) local scale = WorldMapButton:GetEffectiveScale() local x, y = GetCursorPosition() - mx = (( x / scale ) - ( mx - width / 2)) / width * 100 - my = (( my + height / 2 ) - ( y / scale )) / height * 100 + if mx and my then + mx = (( x / scale ) - ( mx - width / 2)) / width * 100 + my = (( my + height / 2 ) - ( y / scale )) / height * 100 + end local px, py = GetPlayerMapPosition("player") if px > 0 and py > 0 then @@ -55,7 +57,7 @@ module.enable = function(self) WorldMapButton.player.text:SetText(string.format("|cffffcc00" .. T["Player"] .. ": |r" .. T["N/A"])) end - if MouseIsOver(WorldMapButton) then + if mx and my and MouseIsOver(WorldMapButton) then WorldMapButton.coords.text:SetText(string.format("|cffffcc00" .. T["Cursor"] .. ": |r%.1f / %.1f", mx, my)) else WorldMapButton.coords.text:SetText(string.format("|cffffcc00" .. T["Cursor"] .. ": |r" .. T["N/A"]))