Mercurial > wow > whistle-master
comparison WhistleMaster.lua @ 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 | 5be6dcc0f0cd |
children | 4bbd39b7df53 |
comparison
equal
deleted
inserted
replaced
20:7c8e685be40d | 21:63bf46cfbd3c |
---|---|
14 | 14 |
15 WM_ClosestNode = nil | 15 WM_ClosestNode = nil |
16 | 16 |
17 local function GetDistance(nX, nY) | 17 local function GetDistance(nX, nY) |
18 local pX, pY = GetPlayerMapPosition("player") | 18 local pX, pY = GetPlayerMapPosition("player") |
19 | 19 local dX, dY |
20 local dX = pX - nX | 20 if pX and pY then |
21 local dY = pY - nY | 21 dX = pX - nX |
22 dY = pY - nY | |
23 else | |
24 return nil | |
25 end | |
22 | 26 |
23 return math.sqrt( ( dX^2 ) + ( dY^2 ) ) | 27 return math.sqrt( ( dX^2 ) + ( dY^2 ) ) |
24 end | 28 end |
25 | 29 |
26 local function GetNode() | 30 local function GetNode() |
43 end | 47 end |
44 | 48 |
45 function UpdateWhistleMaster() | 49 function UpdateWhistleMaster() |
46 if GetCurrentMapContinent() == 8 and WM_validIDs[ select(1, GetCurrentMapAreaID() ) ] and GetMapNameByID(GetCurrentMapAreaID()) == GetZoneText() and not GetNumDungeonMapLevels() then | 50 if GetCurrentMapContinent() == 8 and WM_validIDs[ select(1, GetCurrentMapAreaID() ) ] and GetMapNameByID(GetCurrentMapAreaID()) == GetZoneText() and not GetNumDungeonMapLevels() then |
47 WM_ClosestNode = GetNode() | 51 WM_ClosestNode = GetNode() |
48 WhistleLoc:SetPoint("CENTER", "WorldMapFramePOI" .. WM_ClosestNode.index, 0, 0) | 52 if _G[("WorldMapFramePOI" .. WM_ClosestNode.index)] then |
49 WhistleLoc:Show() | 53 WhistleLoc:SetPoint("CENTER", "WorldMapFramePOI" .. WM_ClosestNode.index, 0, 0) |
50 WhistlePing.Ping:Play() | 54 WhistleLoc:Show() |
51 return true | 55 WhistlePing.Ping:Play() |
56 return true | |
57 else | |
58 return false | |
59 end | |
52 else | 60 else |
53 WhistleLoc:Hide() | 61 WhistleLoc:Hide() |
54 WhistlePing.Ping:Stop() | 62 WhistlePing.Ping:Stop() |
55 return false | 63 return false |
56 end | 64 end |