Add debug options
Add debug buttons Add combatalerter debug
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
local addonname, shared = ...
|
||||
---@cast shared HeimdallShared
|
||||
---@cast addonname string
|
||||
local ModuleName = "Commander"
|
||||
|
||||
local helpMessages = {
|
||||
ru = {
|
||||
@@ -86,6 +87,9 @@ function shared.Commander.Init()
|
||||
player.stinky and "(!!!!)" or "")
|
||||
end
|
||||
end
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("%s: ret = %s", ModuleName, strjoin(", ", unpack(ret))))
|
||||
end
|
||||
return ret
|
||||
end
|
||||
---@param arr table<string, Player>
|
||||
@@ -111,6 +115,9 @@ function shared.Commander.Init()
|
||||
for class, count in pairs(ret) do
|
||||
text[#text + 1] = string.format("%s: %d", class, count)
|
||||
end
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("%s: ret = %s", ModuleName, strjoin(", ", unpack(text))))
|
||||
end
|
||||
return text
|
||||
end
|
||||
---@param arr table<string, Player>
|
||||
@@ -124,6 +131,7 @@ function shared.Commander.Init()
|
||||
return text
|
||||
end
|
||||
local function CountClassPartitionedStinkies()
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("%s: CountClassPartitionedStinkies", ModuleName)) end
|
||||
local res = CountClassPartitioned(HeimdallStinkies)
|
||||
if #res == 0 then
|
||||
return { "No stinkies found" }
|
||||
@@ -131,6 +139,7 @@ function shared.Commander.Init()
|
||||
return res
|
||||
end
|
||||
local function WhoPartitionedStinkies()
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("%s: WhoPartitionedStinkies", ModuleName)) end
|
||||
local res = WhoPartitioned(HeimdallStinkies)
|
||||
if #res == 0 then
|
||||
return { "No stinkies found" }
|
||||
@@ -138,23 +147,33 @@ function shared.Commander.Init()
|
||||
return res
|
||||
end
|
||||
local function CountPartitionedStinkies()
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("%s: CountPartitionedStinkies", ModuleName)) end
|
||||
local res = CountPartitioned(HeimdallStinkies)
|
||||
if #res == 0 then
|
||||
return { "No stinkies found" }
|
||||
end
|
||||
return res
|
||||
end
|
||||
local function HelpRu() return helpMessages.ru end
|
||||
local function HelpEn() return helpMessages.en end
|
||||
local function HelpRu()
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("%s: HelpRu", ModuleName)) end
|
||||
return helpMessages.ru
|
||||
end
|
||||
local function HelpEn()
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("%s: HelpEn", ModuleName)) end
|
||||
return helpMessages.en
|
||||
end
|
||||
local groupInviteFrame = CreateFrame("Frame")
|
||||
groupInviteFrame:SetScript("OnEvent", function(self, event, ...)
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("%s: OnEvent", ModuleName)) end
|
||||
AcceptGroup()
|
||||
groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST")
|
||||
C_Timer.NewTimer(0.1, function()
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("%s: Click", ModuleName)) end
|
||||
_G["StaticPopup1Button1"]:Click()
|
||||
end, 1)
|
||||
end)
|
||||
local function JoinGroup()
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("%s: JoinGroup", ModuleName)) end
|
||||
groupInviteFrame:RegisterEvent("PARTY_INVITE_REQUEST")
|
||||
C_Timer.NewTimer(10, function()
|
||||
groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST")
|
||||
@@ -162,11 +181,13 @@ function shared.Commander.Init()
|
||||
return { "+" }
|
||||
end
|
||||
local function LeaveGroup()
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("%s: LeaveGroup", ModuleName)) end
|
||||
LeaveParty()
|
||||
return {}
|
||||
end
|
||||
---@param target string
|
||||
local function FollowTarget(target)
|
||||
if Heimdall_Data.config.commander.debug then print(string.format("%s: FollowTarget: %s", ModuleName, target)) end
|
||||
if not target then return end
|
||||
FollowUnit(target)
|
||||
return {}
|
||||
@@ -191,20 +212,36 @@ function shared.Commander.Init()
|
||||
local commanderChannelFrame = CreateFrame("Frame")
|
||||
commanderChannelFrame:RegisterEvent("CHAT_MSG_CHANNEL")
|
||||
commanderChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("%s: OnEvent", ModuleName))
|
||||
shared.dumpTable(Heimdall_Data.config.commander)
|
||||
end
|
||||
if not Heimdall_Data.config.commander.enabled then return end
|
||||
local channelId = select(6, ...)
|
||||
local _, channelname = GetChannelName(channelId)
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("%s: channelname = %s", ModuleName, channelname))
|
||||
end
|
||||
if channelname ~= Heimdall_Data.config.commander.masterChannel then return end
|
||||
sender = string.match(sender, "^[^-]+")
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("%s: sender = %s", ModuleName, sender))
|
||||
end
|
||||
|
||||
for _, command in ipairs(commands) do
|
||||
local enabled = Heimdall_Data.config.commander.commands[command.keywordRe] == true or false
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("%s: command.keywordRe = %s: %s", ModuleName, command.keywordRe, tostring(enabled)))
|
||||
end
|
||||
if enabled and
|
||||
(not command.commanderOnly
|
||||
or (command.commanderOnly
|
||||
and sender == Heimdall_Data.config.commander.commander)) then
|
||||
if msg:match(command.keywordRe) then
|
||||
local messages = command.callback({ strsplit(" ", msg) })
|
||||
if Heimdall_Data.config.commander.debug then
|
||||
print(string.format("%s: messages = %s", ModuleName, strjoin(", ", unpack(messages))))
|
||||
end
|
||||
for _, message in ipairs(messages) do
|
||||
---@type Message
|
||||
local msg = {
|
||||
|
Reference in New Issue
Block a user