ea0e63e2f320d3e486c2959d9169bb4adfba0be2
[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 };
12 --local minDungMapID = 1456;
13
14 local function shouldLog()
15     local _, zoneType, difficulty, _, _, _, _, mapID = GetInstanceInfo();
16     if zoneType == "raid" then print(mapID) end
17     if zoneType == "raid" and raidIDs[mapID] then
18         if difficulty == 17 then -- LFR
19             return false;
20         elseif difficulty == 16 then -- Mythic
21             return true;
22         elseif difficulty == 15 then -- Heroic
23             return true;
24         elseif difficulty == 14 then -- Normal
25             return true;
26         end
27     --elseif zoneType == "party" and mapID >= minDungMapID then
28     --    if difficulty == 8 or difficulty == 23 then
29     --        return true;
30     --    end
31     end
32
33     return false;
34 end
35
36 local prevLogging = nil;
37 local function updateZone()
38     local log = shouldLog();
39     if log then
40         LoggingCombat(true);
41         print("<><><><><><><><><><><>");
42         print("Started Combat Log");
43         print("<><><><><><><><><><><>");
44     elseif prevLogging and LoggingCombat() then
45         print("<><><><><><><><><><><>");
46         print("Ended Combat Log");
47         print("<><><><><><><><><><><>");
48     end
49     prevLogging = log;
50 end
51
52 frame:SetScript("OnEvent", function(self, event)
53     if event == "ZONE_CHANGED_NEW_AREA" then
54         CTimerAfter(3, updateZone);
55     elseif event == "CHALLENGE_MODE_START" then
56         CTimerAfter(1, updateZone);
57     end
58 end);
59 frame:RegisterEvent("ZONE_CHANGED_NEW_AREA");
60 --frame:RegisterEvent("CHALLENGE_MODE_START"); -- for logging M+