-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkeys.lua
More file actions
80 lines (70 loc) · 1.79 KB
/
Copy pathkeys.lua
File metadata and controls
80 lines (70 loc) · 1.79 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
-- local vars
local string, canaccessvalue = string, canaccessvalue;
local mpKeyStone = 180653;
local linkKeys, partyChat, debugPrint;
-- frame
local f = CreateFrame("Frame");
f:Hide();
local function onEvent(self, event, ...)
if(event == "CHAT_MSG_PARTY" or event == "CHAT_MSG_PARTY_LEADER") then
local msg = ...;
if(canaccessvalue(msg) and string.lower(msg) == "!keys") then
linkKeys();
end
elseif(event == "ADDON_LOADED") then
local name = ...;
if(name == "!keys") then
--Events
f:UnregisterEvent("ADDON_LOADED");
f:RegisterEvent("CHAT_MSG_PARTY");
f:RegisterEvent("CHAT_MSG_PARTY_LEADER");
end
end
end
f:RegisterEvent("ADDON_LOADED");
f:SetScript("OnEvent", onEvent);
-- functionality
linkKeys = function(debug)
local bag, slot;
local found = {};
for bag = 0, NUM_BAG_SLOTS do
local bagSlots = C_Container.GetContainerNumSlots(bag);
for slot = 1, bagSlots do
local itemInfo = C_Container.GetContainerItemInfo(bag, slot)
if(itemInfo and itemInfo.itemID) then
-- use id
if(itemInfo.itemID == mpKeyStone) then
if(debug) then
debugPrint("Confirmed Same Id: "..itemInfo.itemID);
end
found[#found+1] = itemInfo.hyperlink;
else
-- fallback
local itemName = GetItemInfo(itemInfo.itemID);
if(itemName and string.find(itemName, "Keystone")) then
if(debug) then
debugPrint("New Keystone Id: "..itemInfo.itemID);
end
found[#found+1] = itemInfo.hyperlink;
end
end
end
end
end
if(#found > 0) then
partyChat(table.concat(found, " "));
end
end
partyChat = function(msg)
if(IsInGroup(LE_PARTY_CATEGORY_HOME)) then
SendChatMessage(msg, "PARTY");
else
debugPrint(msg);
end
end
debugPrint = function(msg)
print("!keys: " .. msg);
end
function ExclamationKeysDebugTrigger()
linkKeys(true);
end