From 904c5abc5a72b80c407e041b5c19d5c6914c557f Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Sat, 19 Dec 2020 20:39:26 -0500 Subject: [PATCH] Add !keys command --- MyAddon.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/MyAddon.lua b/MyAddon.lua index 8f3712c..69986ed 100755 --- a/MyAddon.lua +++ b/MyAddon.lua @@ -9,10 +9,18 @@ StaticPopupDialogs["REPAIR_ALERT"] = { preferredIndex = 3 } +MyAddon.keyItemID = 138019 + function MyAddon.OnEvent(self, event, ...) events[event](self, ...) end +function events:CHAT_MSG_PARTY(message, ...) + if text == '!keys' then + MyAddon.announceKey() + end +end + function events:PLAYER_LOGIN(...) -- found from some forums local b=ActionButton8 _MH=_MH or(b:SetAttribute("*type5","macro")or SecureHandlerWrapScript(b,"PreClick",b,'Z=IsAltKeyDown()and 0 or(Z or 0)%8+1 self:SetAttribute("macrotext5","/wm [nomod]"..Z)'))or 1 @@ -38,6 +46,19 @@ function events:PLAYER_ROLES_ASSIGNED(...) if MyAddon.amTankInParty() then MyAddon.markSelfSquare() end end +function MyAddon.announceKey() + for bag = 0, NUM_BAG_SLOTS do + for slot = 1, GetContainerNumSlots(bag)do + if GetContainerItemID(bag, slot) == MyAddon.keyItemID then + local link = GetContainerItemLink(bag, slot) + SendChatMessage(link, "PARTY") + + return + end + end + end +end + function MyAddon.needsRepair() local slots = { "HeadSlot", "ShoulderSlot", "ChestSlot", "WristSlot", "HandsSlot",