This repository was archived by the owner on Sep 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSimpleAutoCombatLog.lua
63 lines (50 loc) · 1.54 KB
/
SimpleAutoCombatLog.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
local addonName, SimpleAutoCombatLog = ...;
local EventHandler = CreateFrame("Frame");
local LookForMob = false;
EventHandler:RegisterEvent("ZONE_CHANGED_NEW_AREA");
EventHandler:RegisterEvent("PLAYER_TARGET_CHANGED");
EventHandler:SetScript("OnEvent", function(self, event, ...)
if event == "ZONE_CHANGED_NEW_AREA" then
SimpleAutoCombatLog:OnZoneChanged(...);
elseif LookForMob and event == "PLAYER_TARGET_CHANGED" then
SimpleAutoCombatLog:OnTargetChanged(...);
end
end);
function SimpleAutoCombatLog:OnZoneChanged(...)
local zone = GetRealZoneText();
if self:IsInList( self.Zones.ZoneOnly, zone ) then -- No Mob needs to be tagged
self:StartLog();
elseif self:IsInList( self.Zones.ZoneAndMob.Zones, zone ) then -- Mobs need to be tagged
LookForMob = true;
else
self:StopLog();
LookForMob = false;
end
end
function SimpleAutoCombatLog:OnTargetChanged(...)
local name = UnitName("target");
if self:IsInList( self.Zones.ZoneAndMob.Mobs, name ) then
self:StartLog();
end
end
function SimpleAutoCombatLog:StartLog()
if not LoggingCombat() then
LoggingCombat(true);
print("|cffffff00".. L["Combatlog enabled"] .."|r");
SetCVar("advancedCombatLogging", 1);
end
end
function SimpleAutoCombatLog:StopLog()
if LoggingCombat() then
LoggingCombat(false);
print("|cffffff00".. L["Combatlog disabled"] .."|r");
end
end
function SimpleAutoCombatLog:IsInList( list, search_value )
for _, value in pairs( list ) do
if value == search_value then
return true;
end
end
return false;
end