From 6ed8432c4c34d5ee3b1903ac1d67e4bb097c5de7 Mon Sep 17 00:00:00 2001 From: James Whitehead II Date: Thu, 20 Oct 2011 16:50:27 +0100 Subject: [PATCH] Add an option to use waypoints outside zone to find closest It will still restrict the search to the current continent, but will now lead you outside the zone, if that waypoint is closer. This option is disabled by default. --- TomTom.lua | 39 ++++++++++++++++++++++++++++++--------- TomTom_Config.lua | 8 ++++++++ 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/TomTom.lua b/TomTom.lua index 236d424..804879b 100755 --- a/TomTom.lua +++ b/TomTom.lua @@ -66,6 +66,7 @@ function TomTom:Initialize(event, addon) title_scale = 1, title_alpha = 1, setclosest = true, + closestusecontinent = false, enablePing = false, }, minimap = { @@ -1038,17 +1039,37 @@ end function TomTom:GetClosestWaypoint() local m,f,x,y = self:GetCurrentPlayerPosition() + local c = lmd:GetContinentFromMap(m) + local closest_waypoint = nil local closest_dist = nil - if waypoints[m] then - for key, waypoint in pairs(waypoints[m]) do - local dist, x, y = TomTom:GetDistanceToWaypoint(waypoint) - if (dist and closest_dist == nil) or (dist and dist < closest_dist) then - closest_dist = dist - closest_waypoint = waypoint - end - end - end + + if not self.profile.arrow.closestusecontinent then + -- Simple search within this zone + if waypoints[m] then + for key, waypoint in pairs(waypoints[m]) do + local dist, x, y = TomTom:GetDistanceToWaypoint(waypoint) + if (dist and closest_dist == nil) or (dist and dist < closest_dist) then + closest_dist = dist + closest_waypoint = waypoint + end + end + end + else + -- Search all waypoints on this continent + for map, waypoints in pairs(waypoints) do + if c == lmd:GetContinentFromMap(map) then + for key, waypoint in pairs(waypoints) do + local dist, x, y = TomTom:GetDistanceToWaypoint(waypoint) + if (dist and closest_dist == nil) or (dist and dist < closest_dist) then + closest_dist = dist + closest_waypoint = waypoint + end + end + end + end + end + if closest_dist then return closest_waypoint end diff --git a/TomTom_Config.lua b/TomTom_Config.lua index 8dbabc7..57d7dc1 100644 --- a/TomTom_Config.lua +++ b/TomTom_Config.lua @@ -220,6 +220,14 @@ local function createconfig() width = "double", arg = "arrow.setclosest", }, + closestusecontinent = { + order = 10, + type = "toggle", + name = L["Allow closest waypoint to be outside current zone"], + desc = L["Normally when TomTom sets the closest waypoint it chooses the waypoint in your current zone. This option will cause TomTom to search for any waypoints on your current continent. This may lead you outside your current zone, so it is disabled by default."], + width = "double", + arg = "arrow.closestusecontinent", + }, heredistance = { order = 9, type = "range", -- 1.7.9.5