changeset 21:63bf46cfbd3c

Added some validation behavior to nip a few annoying errors in the bud.
author Vynn <mischivin@gmail.com>
date Mon, 20 Feb 2017 00:02:29 -0500
parents 7c8e685be40d
children 90c07a6fec4b
files WhistleMaster.lua
diffstat 1 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/WhistleMaster.lua	Mon Dec 26 11:21:55 2016 -0500
+++ b/WhistleMaster.lua	Mon Feb 20 00:02:29 2017 -0500
@@ -16,9 +16,13 @@
 
 local function GetDistance(nX, nY)
 	local pX, pY = GetPlayerMapPosition("player")
-
-	local dX = pX - nX
-    local dY = pY - nY
+	local dX, dY
+	if pX and pY then
+		dX = pX - nX
+    	dY = pY - nY
+    else 
+    	return nil
+    end
  
 	return math.sqrt( ( dX^2 ) + ( dY^2 ) )
 end
@@ -45,10 +49,14 @@
 function UpdateWhistleMaster()
 	if GetCurrentMapContinent() == 8 and WM_validIDs[ select(1, GetCurrentMapAreaID() ) ] and GetMapNameByID(GetCurrentMapAreaID()) == GetZoneText() and not GetNumDungeonMapLevels() then
 		WM_ClosestNode = GetNode()
-		WhistleLoc:SetPoint("CENTER", "WorldMapFramePOI" .. WM_ClosestNode.index, 0, 0)
-		WhistleLoc:Show()
-		WhistlePing.Ping:Play()
-		return true
+		if _G[("WorldMapFramePOI" .. WM_ClosestNode.index)] then
+			WhistleLoc:SetPoint("CENTER", "WorldMapFramePOI" .. WM_ClosestNode.index, 0, 0)
+			WhistleLoc:Show()
+			WhistlePing.Ping:Play()
+			return true
+		else
+			return false
+		end
 	else
 		WhistleLoc:Hide()
 		WhistlePing.Ping:Stop()