Code:
local UpdateInterval, TimeSinceLastUpdate, x, y = 0.3, 0;
GUICordsFrame:SetScript("OnUpdate", function(self, elapsed)
TimeSinceLastUpdate = TimeSinceLastUpdate + elapsed
while (TimeSinceLastUpdate > UpdateInterval) do
x,y = GetPlayerMapPosition("player")
GUICordsFrameText:SetFormattedText("%.2f %.2f", 100*x, 100*y)
TimeSinceLastUpdate = TimeSinceLastUpdate - UpdateInterval
end
end)
Just on a general note, the while loop is entirely pointless and should be replaced by an if. Aside from that, we'll have to save which map is currently displayed, ask for the map of the zone the player is in, query coordinates, and then restore the old map:
lua Code:
local UpdateInterval, TimeSinceLastUpdate, x, y = 0.3, 0;
GUICordsFrame:SetScript("OnUpdate", function(self, elapsed)
TimeSinceLastUpdate = TimeSinceLastUpdate + elapsed
if TimeSinceLastUpdate < UpdateInterval then return end
-- Copy current map state
local continent, zone, dungeon = GetCurrentMapContinent(), GetCurrentMapZone(), GetCurrentMapDungeonLevel();
-- Change map to display the zone the player is in.
SetMapToCurrentZone();
-- Grab our data
TimeSinceLastUpdate, x, y = 0, GetPlayerMapPosition("player");
-- Restore map state based on copied data
SetMapZoom(continent, zone);
if dungeon then SetDungeonMapLevel(dungeon); end
-- Use retrieved coordinates however you like.
GUICordsFrameText:SetFormattedText("%.2f %.2f", 100*x, 100*y)
end)