0
@@ -4,19 +4,35 @@ local colorneed, colorgreed = "|cffff0000", "|cffffff00"
0
local coloredwords = {Greed = colorgreed.."Greed", Need = colorneed.."Need"}
0
+local function Print(...) ChatFrame1:AddMessage(string.join(" ", "|cFF33FF99GreedBeacon|r:", ...)) end
0
+local debugf = tekDebug and tekDebug:GetFrame("GreedBeacon")
0
+local function Debug(...) if debugf then debugf:AddMessage(string.join(", ", ...)) end end
0
local chatframes = {[ChatFrame1] = false, [ChatFrame2] = false, [ChatFrame3] = false, [ChatFrame4] = false, [ChatFrame5] = false, [ChatFrame6] = false, [ChatFrame7] = false}
0
for frame in pairs(chatframes) do
0
- for i,v in pairs(frame.messageTypeList) do if v == "LOOT" then chatframes[frame] = true end end
0
+ for i,v in pairs(frame.messageTypeList) do
0
+ chatframes[frame] = true
0
+ Debug("Initializing", frame:GetName())
0
local origadd, origrem = ChatFrame_AddMessageGroup, ChatFrame_RemoveMessageGroup
0
ChatFrame_AddMessageGroup = function(frame, channel, ...)
0
- if channel == "LOOT" then chatframes[frame] = true end
0
+ if channel == "LOOT" then
0
+ chatframes[frame] = true
0
+ Debug("ChatFrame_AddMessageGroup", frame:GetName())
0
return origadd(frame, channel, ...)
0
ChatFrame_RemoveMessageGroup = function(frame, channel, ...)
0
- if channel == "LOOT" then chatframes[frame] = false end
0
+ if channel == "LOOT" then
0
+ chatframes[frame] = false
0
+ Debug("ChatFrame_RemoveMessageGroup", frame:GetName())
0
return origrem(frame, channel, ...)
0
@@ -25,6 +41,7 @@ local function FindRoll(link, player, hasselected)
0
for i,roll in ipairs(rolls) do
0
if roll._link == link and not roll._winner and (not roll[player] or hasselected) then return roll end
0
+ Debug("New roll started", link)
0
local newroll = {_link = link}
0
table.insert(rolls, newroll)
0
@@ -37,6 +54,7 @@ f:SetScript("OnEvent", function(self, event, msg)
0
local rolltype, rollval, link, player = msg:match("(.+) Roll . (%d+) for (.+) by (.+)")
0
local roll = FindRoll(link, player, true)
0
+ Debug("Roll detected", player, rolltype, rollval, link)
0
roll[player] = (rolltype == "Need" and colorneed or colorgreed)..rollval
0
@@ -45,6 +63,7 @@ f:SetScript("OnEvent", function(self, event, msg)
0
local player, selection, link = msg:match("(.*) has?v?e? selected (.+) for: (.+)")
0
player = player == "You" and UnitName("player") or player
0
+ Debug("Selection detected", player, selection, link)
0
FindRoll(link, player)[player] = coloredwords[selection]
0
@@ -56,22 +75,23 @@ f:SetScript("OnEvent", function(self, event, msg)
0
if roll._link == link and roll[player] and not roll._printed then
0
+ Debug("Roll completed", roll._type or "nil", i, player, link)
0
local msg = string.format("%s|Hgreedbeacon:%d|h[%s roll]|h|r %s won %s ", roll._type == "Need" and colorneed or colorgreed, i, roll._type or "???", player, link)
0
for frame,val in pairs(chatframes) do if val then frame:AddMessage(msg) end end
0
-
ChatFrame6:AddMessage("GB NO MATCH: "..msg)
0
+
Print("No match found for", msg)
0
ChatFrame_AddMessageEventFilter("CHAT_MSG_LOOT", function(msg)
0
- if msg:match("(.*) won: (.+)")
0
- or msg:match(" has?v?e? selected .+ for: ")
0
- or msg:match(" Roll . %d+ for .+ by ")
0
- or (msg:match(" passed on: ") and not msg:match("Everyone passed on: ")) then return true end
0
+ if msg:match("(.*) won: (.+)") or msg:match(" has?v?e? selected .+ for: ") or msg:match(" Roll . %d+ for .+ by ") or (msg:match(" passed on: ") and not msg:match("Everyone passed on: ")) then
0
+ Debug("Supressing chat message", msg)
Comments
No one has commented yet.