f8c2ec88ee5b756f135bb8768558ffe1e7759926
[wowui.git] / OmaLog / Logging.lua
1 -- Logging.lua
2 local _;
3 local print = print;
4 local LoggingCombat = LoggingCombat;
5 local GetInstanceInfo = GetInstanceInfo;
6 local CTimerAfter = C_Timer.After;
7 local frame = CreateFrame("Frame", "OmaLogger");
8 frame:Hide();
9
10 local raidIDs = {
11     [1861] = "Uldir",
12 };
13 --local minDungMapID = 1456;
14
15 local function shouldLog()
16     local _, zoneType, difficulty, _, _, _, _, mapID = GetInstanceInfo();
17     if zoneType == "raid" then print(mapID) end
18     if zoneType == "raid" and raidIDs[mapID] then
19         if difficulty == 17 then -- LFR
20             return false;
21         elseif difficulty == 16 then -- Mythic
22             return true;
23         elseif difficulty == 15 then -- Heroic
24             return true;
25         elseif difficulty == 14 then -- Normal
26             return true;
27         end
28     --elseif zoneType == "party" and mapID >= minDungMapID then
29     --    if difficulty == 8 or difficulty == 23 then
30     --        return true;
31     --    end
32     end
33
34     return false;
35 end
36
37 local prevLogging = nil;
38 local function updateZone()
39     local log = shouldLog();
40     if log then
41         LoggingCombat(true);
42         print("<><><><><><><><><><><>");
43         print("Started Combat Log");
44         print("<><><><><><><><><><><>");
45     elseif prevLogging and LoggingCombat() then
46         print("<><><><><><><><><><><>");
47         print("Ended Combat Log");
48         print("<><><><><><><><><><><>");
49     end
50     prevLogging = log;
51 end
52
53 frame:SetScript("OnEvent", function(self, event)
54     if event == "ZONE_CHANGED_NEW_AREA" then
55         CTimerAfter(3, updateZone);
56     elseif event == "CHALLENGE_MODE_START" then
57         CTimerAfter(1, updateZone);
58     end
59 end);
60 frame:RegisterEvent("ZONE_CHANGED_NEW_AREA");
61 --frame:RegisterEvent("CHALLENGE_MODE_START"); -- for logging M+