Quantcast

Remove objective POIs before adding a new one

James Whitehead II [05-06-10 - 10:27]
Remove objective POIs before adding a new one
Filename
TomTom_POIIntegration.lua
diff --git a/TomTom_POIIntegration.lua b/TomTom_POIIntegration.lua
index 3617085..27fc1d9 100644
--- a/TomTom_POIIntegration.lua
+++ b/TomTom_POIIntegration.lua
@@ -99,6 +99,8 @@ hooksecurefunc("QuestPOI_DisplayButton", function(parentName, buttonType, button
       end
 end)

+local setPoints = {}
+
 -- This code will enable auto-tracking of closest quest objectives.  To
 -- accomplish this, it hooks the WatchFrame_Update function, and when it
 -- is called, it sets a waypoint to the closest quest id.
@@ -127,7 +129,11 @@ local function updateClosestPOI()
             -- Set a waypoint for this POI, it should be the higehst
             local questFrame = findQuestFrameFromQuestIndex(questID)
             if questFrame then
-                setQuestWaypoint(questFrame.poiIcon)
+                for idx, uid in ipairs(setPoints) do
+                    TomTom:RemoveWaypoint(uid)
+                end
+                local uid = setQuestWaypoint(questFrame.poiIcon)
+                table.insert(setPoints, uid)
             end
         end
     end