Quantcast

Fix handling of floors (fixes 28)

James Whitehead II [05-31-11 - 15:31]
Fix handling of floors (fixes 28)
Filename
TomTom.lua
TomTom_POIIntegration.lua
diff --git a/TomTom.lua b/TomTom.lua
index 2d7c8e6..a27214c 100755
--- a/TomTom.lua
+++ b/TomTom.lua
@@ -217,9 +217,11 @@ function TomTom:GetCurrentPlayerPosition()
     -- Try to get the position without 'flipping' the map
     local m, f, x, y = astrolabe:GetUnitPosition("player", true)
     if m and x and y and not (x <= 0 or y <= 0) then
-        local floors = astrolabe:GetNumFloors(m)
-        local floor = floors == 0 and 0 or 1
-        return m, floor, x, y
+        if not f then
+            local floors = astrolabe:GetNumFloors(m)
+            f = floors == 0 and 0 or 1
+        end
+        return m, f, x, y
     end
 end

diff --git a/TomTom_POIIntegration.lua b/TomTom_POIIntegration.lua
index ba5e239..c991a26 100644
--- a/TomTom_POIIntegration.lua
+++ b/TomTom_POIIntegration.lua
@@ -32,7 +32,7 @@ local function ObjectivesChanged()

     local map, floor = GetCurrentMapAreaID()
     local floors = astrolabe:GetNumFloors(map)
-    floor = floors == 0 and 0 or 1
+    floor = floor and floor or (floors == 0 and 0 or 1)

     local px, py = GetPlayerMapPosition("player")