From 826e9434294eff0e371b14538b02231678a6c485 Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Mon, 12 Jan 2009 17:43:59 +0000 Subject: [PATCH] * Fix an error when calling /wayb in a non-zoned area * Add uid = TomTom:GetClosestWaypoint() * Altered the behavior of "Clear Waypoint" when interacting with "Automatically set closest waypoint". When you clear a waypoint, if the 'closest' waypoint is the waypoint you cleared it will not be set --- TomTom.lua | 17 ++++++++++++++--- TomTom_CrazyArrow.lua | 9 +++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/TomTom.lua b/TomTom.lua index ab6c2e2..edf2cc1 100755 --- a/TomTom.lua +++ b/TomTom.lua @@ -743,6 +743,10 @@ function TomTom:AddZWaypoint(c, z, x, y, desc, persistent, minimap, world, custo local coord = self:GetCoord(x / 100, y / 100) local zone = self:GetMapFile(c, z) + if not zone then + return + end + -- Ensure there isn't already a waypoint at this location if waypoints[zone] then for uid in pairs(waypoints[zone]) do @@ -921,7 +925,7 @@ for cidx,c in ipairs{GetMapContinents()} do end end -function TomTom:SetClosestWaypoint() +function TomTom:GetClosestWaypoint() local c,z,x,y = Astrolabe:GetCurrentPlayerPosition() local zone = TomTom:GetMapFile(c, z) local closest_uid = nil @@ -936,8 +940,15 @@ function TomTom:SetClosestWaypoint() end end if closest_dist then - local data = waypoints[closest_uid] - TomTom:SetCrazyArrow(closest_uid, TomTom.profile.arrow.arrival, data.title) + return closest_uid + end +end + +function TomTom:SetClosestWaypoint() + local uid = self:GetClosestWaypoint() + if uid then + local data = waypoints[uid] + TomTom:SetCrazyArrow(uid, TomTom.profile.arrow.arrival, data.title) end end diff --git a/TomTom_CrazyArrow.lua b/TomTom_CrazyArrow.lua index 8ca2606..b985cd8 100644 --- a/TomTom_CrazyArrow.lua +++ b/TomTom_CrazyArrow.lua @@ -297,10 +297,15 @@ local dropdown_info = { -- Clear waypoint from crazy arrow text = L["Clear waypoint from crazy arrow"], func = function() + local prior = active_point + active_point = nil if TomTom.profile.arrow.setclosest then - TomTom:SetClosestWaypoint() - return + local uid = TomTom:GetClosestWaypoint() + if uid and uid ~= prior then + TomTom:SetClosestWaypoint() + return + end end end, }, -- 1.7.9.5