Add an option to use waypoints outside zone to find closest
James Whitehead II [10-20-11 - 15:50]
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.
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",