From ff2c18b908705231981b6a8b15fb59af2e81b771 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoffer=20Stokb=C3=A6k?= Date: Sat, 3 Feb 2018 22:29:00 +0100 Subject: [PATCH] Release --- README.md | 6 +++++ ResurrectionAnnounce.toc | 11 +++++++++ cmd.lua | 29 ++++++++++++++++++++++++ core.lua | 48 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 ResurrectionAnnounce.toc create mode 100644 cmd.lua create mode 100644 core.lua diff --git a/README.md b/README.md index 874fcad..5a1ffcb 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,8 @@ # ResurrectionAnnounce Plugin for HealComm (WoW 1.12.1) to announce who you are resurrecting + +Usage:|cffffff55 /sayres {chat|help} +chat {number}: + * 0: Dynamic (Party/Raid) + * 1: Raid + * 2: Say \ No newline at end of file diff --git a/ResurrectionAnnounce.toc b/ResurrectionAnnounce.toc new file mode 100644 index 0000000..b77e70a --- /dev/null +++ b/ResurrectionAnnounce.toc @@ -0,0 +1,11 @@ +## Interface: 11200 +## Title: |cFFFF8080R|resurrection |cFFFF8080A|rnnouncement +## Author: stokbaek +## Notes: Plugin That Adds Resurrection Announce to Chat +## Version: 1.0 +## Note: This Plugin needs to either have HealComm or LunaFrames installed to work +## SavedVariablesPerCharacter: sayres_options + +# main +core.lua +cmd.lua \ No newline at end of file diff --git a/cmd.lua b/cmd.lua new file mode 100644 index 0000000..65e5260 --- /dev/null +++ b/cmd.lua @@ -0,0 +1,29 @@ +SLASH_SAYRES1, SLASH_SAYRES2 = '/sayres', '/sr' +function SlashCmdList.SAYRES(msg, editbox) + local cmd, opt = strsplit(" ", msg) + local chatformat_cmd = "|cFFFF8080rA |\124|cffffff55" + local chatformat_info = "|cFFFF8080rA |\124|cffff0000" + if cmd == "chat" then + if opt == "0" then + DEFAULT_CHAT_FRAME:AddMessage(chatformat_cmd.."Chat Output set to: |cff00ff00DYNAMIC") + elseif opt == "1" then + DEFAULT_CHAT_FRAME:AddMessage(chatformat_cmd.."Chat Output set to: |cffff7d00RAID") + elseif opt == "2" then + DEFAULT_CHAT_FRAME:AddMessage(chatformat_cmd.."Chat Output set to: |rSAY") + else + DEFAULT_CHAT_FRAME:AddMessage(chatformat_info.."Unknown Chat Option") + return + end + ra_options[cmd] = opt + elseif msg == "help" or "" then + if msg ~= "help" then + DEFAULT_CHAT_FRAME:AddMessage(chatformat_info.."Unkown Command") + DEFAULT_CHAT_FRAME:AddMessage(chatformat_info.."----") + end + DEFAULT_CHAT_FRAME:AddMessage(chatformat_info.."About:|cffffff55 Announces when you resurrect a player in your Raid/Party") + DEFAULT_CHAT_FRAME:AddMessage(chatformat_info.."Usage:|cffffff55 /sayres {chat\124|help}") + DEFAULT_CHAT_FRAME:AddMessage(chatformat_info.."chat {number}:|cffffff55 0, Dynamic (Party/Raid); 1, Party; 2, Say") + DEFAULT_CHAT_FRAME:AddMessage(chatformat_info.."help:|cffffff55 Shows this message") + return + end +end \ No newline at end of file diff --git a/core.lua b/core.lua new file mode 100644 index 0000000..8e5b5e3 --- /dev/null +++ b/core.lua @@ -0,0 +1,48 @@ +local events = {} +local ress = {} + +ra_options = {} + +rahealcomm = CreateFrame("Frame") +rahealcomm:RegisterEvent("CHAT_MSG_ADDON") +rahealcomm:SetScript("OnEvent", function() + if event == "CHAT_MSG_ADDON" and arg1 == "HealComm" then + this:ParseChatMessage(arg4, arg2) + end +end) + +rahealcomm:SetScript("OnUpdate", function() + for timestamp, targets in pairs(events) do + if GetTime() >= timestamp then + for id, target in pairs(targets) do + rahealcomm:TriggerUpdate(target) + end + events[timestamp] = nil + end + end +end) + +function rahealcomm:ParseChatMessage(sender, msg) + local _, _, evtype, target = string.find(msg, '(Resurrection)/(%a+)/(start)/') + if evtype and target then + rahealcomm:Ress(sender, target) + return + end +end + +function rahealcomm:Ress(sender, target) + ress[target] = ress[target] or {} + ress[target][sender] = true + + if sender == UnitName("player") and target ~= UnitName("player") then + if ra_options.chat == "0" then + SendChatMessage("Resurrecting " .. target, UnitInRaid("player") and "Raid" or "Party") + elseif ra_options.chat == "1" then + if UnitInRaid("player") and "Raid" then + SendChatMessage("Resurrecting " .. target, "Raid") + end + else + SendChatMessage("Resurrecting " .. target, "Say") + end + end +end \ No newline at end of file