-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpenThosePouches.lua
140 lines (123 loc) · 3.19 KB
/
OpenThosePouches.lua
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
local isOpening_lock = false -- semaphor to keep us from recursively checking
local isVendorDialogOpen_lock = false -- semaphor to not attempt while talking to a vendor (tries to sell the pouch)
local delayBetweenSearches = 0.75 -- seconds (not MS) to wait between bag opens
local ignoredItems = {
-- warped-pocket-dimension, I feel like this was made specifically to mess with me :)
190382,
-- Encaged souls from the Zapthrottle Soul Inhaler
200931,
200932,
200934,
200936,
-- Items requiring lockpicking
-- Last updated for 11.0
-- https://www.wowhead.com/items?filter=10:195;1:2;:0
-- use the Copy icon for ID
16885,
63349,
68729,
203743,
198657,
186161,
180532,
190954,
179311,
5760,
43575,
16884,
4636,
180522,
29569,
31952,
180533,
88165,
4634,
16882,
43624,
12033,
16883,
88567,
5758,
43622,
121331,
4638,
5759,
4637,
169475,
7209,
6354,
45986,
4632,
13918,
116920,
4633,
188787,
6355,
194037,
13875,
186160,
204307,
220376,
106895,
191296
}
local function IsPouch(container, slot)
local itemInfo = C_Container.GetContainerItemInfo(container, slot)
if itemInfo == nil then
return false
end
if itemInfo["hasLoot"] == false then
return false
end
for _i, lockedItemId in ipairs(ignoredItems) do
if lockedItemId == itemInfo["itemID"] then
return false
end
end
local link = C_Container.GetContainerItemLink(container, slot)
local _, _, _, _, itemMinLevel = C_Item.GetItemInfo(link)
if itemMinLevel ~= nil and itemMinLevel > UnitLevel("player") then
return false
end
return true
end
local function OpenNextPouch()
-- print("Looking for pouches")
for container = BACKPACK_CONTAINER, NUM_BAG_SLOTS do
for slot = 1, C_Container.GetContainerNumSlots(container) do
if IsPouch(container, slot) == true then
local isNotCasting = UnitCastingInfo("player") == nil
if isVendorDialogOpen_lock == false and isNotCasting and not InCombatLockdown() then
C_Container.UseContainerItem(container, slot)
end
C_Timer.After(delayBetweenSearches, OpenNextPouch)
return
end
end
end
isOpening_lock = false
end
local function OpenAllPouchesEventually()
if isOpening_lock == true then
return
end
isOpening_lock = true
-- print("scheduling")
C_Timer.After(delayBetweenSearches, OpenNextPouch)
end
-- invisible frame for hooking events
local f = CreateFrame("frame")
f:SetScript("OnEvent", OpenAllPouchesEventually)
f:RegisterEvent("ITEM_PUSH")
local function ToggleVendorLock(_, event_name)
if event_name == "MERCHANT_SHOW" then
isVendorDialogOpen_lock = true
end
if event_name == "MERCHANT_CLOSED" then
isVendorDialogOpen_lock = false
end
end
local g = CreateFrame("frame")
g:SetScript("OnEvent", ToggleVendorLock)
g:RegisterEvent("MERCHANT_SHOW")
g:RegisterEvent("MERCHANT_CLOSED")