89d259f - New debuffs to track in TMW
[wowui.git] / OmaCoords / Coords.lua
1 -- Coords.lua
2 local _;
3 local CTimerAfter = C_Timer.After;
4
5 local updating = false;
6 local frame = CreateFrame("Frame", "OmaCoords", UIParent);
7 frame:SetPoint("CENTER", UIParent, "CENTER", 0, 60);
8 frame:SetWidth(1);
9 frame:SetHeight(1);
10 frame.text = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
11 frame.text:SetPoint("CENTER");
12 frame:Hide();
13
14 local function update()
15     if updating then
16         local vec = C_Map.GetPlayerMapPosition(C_Map.GetBestMapForUnit("player"), "player");
17         if vec then
18             local x, y = vec:GetXY();
19             frame.text:SetFormattedText("%.1f, %.1f", x*100, y*100);
20         else
21             frame.text:SetFormattedText("not available");
22         end
23         CTimerAfter(0.2, update);
24     end
25 end
26
27 SLASH_OMACOORDS1 = "/coords";
28 function SlashCmdList.OMACOORDS()
29     if frame:IsShown() then
30         updating = false;
31         frame:Hide();
32     else
33         updating = true;
34         update();
35         frame:Show();
36     end
37 end