-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseller.lua
More file actions
225 lines (178 loc) · 6.83 KB
/
Copy pathseller.lua
File metadata and controls
225 lines (178 loc) · 6.83 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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
local function Print(...) ChatFrame1:AddMessage(string.join(" ", "|cFF33FF99tekauc seller|r:", ...)) end
local debugf = tekDebug and tekDebug:GetFrame("tekauc_seller")
local function Debug(...) if debugf then debugf:AddMessage(string.join(", ", ...)) end end
local ids = LibStub("tekIDmemo")
local pendingbag, pendingslot, batchitem, batchprice
local f = CreateFrame("Frame")
f:Hide()
local queue = {}
local function finditem(id, size)
for bag=0,4 do
for slot=1,GetContainerNumSlots(bag) do
local link = GetContainerItemLink(bag, slot)
if link and ids[link] == id then return bag, slot end
end
end
end
local function createauction(bag, slot, price, stacksize, time)
-- local bag, slot = finditem(id)
local link = GetContainerItemLink(bag, slot)
if not link then return end
local id = ids[link]
stacksize, time = stacksize or 1, time or 12*60
local numstacks = math.floor(GetItemCount(id)/stacksize)
Debug("Posting auction", id, bag, slot, price, stacksize, numstacks, time)
Print("Posting", numstacks, "stacks of", link, "x"..stacksize, "for sale at", price)
local newtimeformat = { [12*60]=1, [24*60]=2, [48*60]=3}
time = newtimeformat[time]
Debug("time now == ".. time .. ", since Blizzard sucks at API changes!")
PickupContainerItem(bag, slot)
if GetCursorInfo() == "item" then
ClickAuctionSellItemButton()
ClearCursor()
end
if stacksize == 1 and numstacks == 1 then
pendingbag, pendingslot, batchitem, batchprice, batchstack = bag, slot, id, price, stack
f:RegisterEvent("BAG_UPDATE")
else
f:RegisterEvent("AUCTION_MULTISELL_UPDATE")
end
StartAuction(price, price, time, stacksize, numstacks)
end
local function processqueue()
Debug("Processing next item in queue")
local id, price, stack = table.remove(queue, 1), table.remove(queue, 1), table.remove(queue, 1)
if id and price and stack then
local bag, slot = finditem(id)
if bag and slot then createauction(bag, slot, price, stack)
else return processqueue() end
else
Debug("No more items in queue")
end
end
function tekauc:PostBatch(id, price, stack)
if price <= 0 then return end
table.insert(queue, id)
table.insert(queue, price)
table.insert(queue, stack)
if not batchitem then return processqueue() end
end
local elap = 0
f:SetScript("OnShow", function(self) elap = 0 end)
f:SetScript("OnHide", function(self) processqueue() end)
f:SetScript("OnUpdate", function(self, e)
elap = elap + e
if elap >= 1 then self:Hide() end
end)
f:SetScript("OnEvent", function(self, event, ...)
if event == "AUCTION_MULTISELL_UPDATE" then
local posted, total = ...
if posted ~= total then return end
f:UnregisterEvent("AUCTION_MULTISELL_UPDATE")
f:Show()
else
local bag = ...
if bag ~= pendingbag or GetContainerItemLink(pendingbag, pendingslot) then return end
local bag, slot = finditem(batchitem, batchstack)
if (bag and slot) then return createauction(bag, slot, batchprice) end
pendingbag, pendingslot, batchitem, batchprice = nil
f:UnregisterEvent("BAG_UPDATE")
processqueue()
end
end)
local function GetPrice(link, stack)
local price = link and tekauc.GetAuctionBuyout(link)
if not price then return end
local stackprice = price*stack
if stackprice > 10000 then stackprice = math.floor((stackprice - 1)/500) * 500 end -- Rounds down to the next multiple of 5s if > 1g
return stackprice
end
local orig = ContainerFrameItemButton_OnModifiedClick
ContainerFrameItemButton_OnModifiedClick = function(self, button, ...)
if AuctionFrame:IsShown() and IsAltKeyDown() then
local bag, slot = this:GetParent():GetID(), this:GetID()
local link = bag and slot and GetContainerItemLink(bag, slot)
local stacksize = IsShiftKeyDown() and 1 or select(2, GetContainerItemInfo(bag, slot))
local price = GetPrice(link, stacksize)
if not price then
if link then Print("Cannot find price for", link) else Print("Error finding item") end
return orig(self, button, ...)
end
tekauc:PostBatch(ids[link], price, stacksize)
else return orig(self, button, ...) end
end
local PADDING = 4
local bgFrame = {bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", insets = {left = PADDING, right = PADDING, top = PADDING, bottom = PADDING},
tile = true, tileSize = 16, edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 16}
local f = CreateFrame("Frame", nil, AuctionFrame)
f:SetPoint("TOP", 0, 13)
f:SetPoint("RIGHT", -25, 0)
f:SetWidth(248)
f:SetHeight(53)
f:SetFrameLevel(AuctionFrame:GetFrameLevel()-1)
f:SetBackdrop(bgFrame)
f:SetBackdropBorderColor(TOOLTIP_DEFAULT_COLOR.r, TOOLTIP_DEFAULT_COLOR.g, TOOLTIP_DEFAULT_COLOR.b)
f:SetBackdropColor(TOOLTIP_DEFAULT_BACKGROUND_COLOR.r, TOOLTIP_DEFAULT_BACKGROUND_COLOR.g, TOOLTIP_DEFAULT_BACKGROUND_COLOR.b)
local blist = [[
818 774 1206 1210 1529 1705
3864 7909 7910 12361 12364 12799 12800
23077 21929 23112 23079 23117 23107
23436 23439 23440 23437 23438 23441
32227 32231 32229 32249 32228 32230
36917 36929 36920 36932 36923 36926
36918 36930 36921 36933 36924 36927
5498 5500 7971 13926 24478 36783 24479
25867 25868 36784 41266 41334 42225
11382 12363 19774
36919 36931 36922 36934 36925 36928
]]
local function IsEnchantScroll(link)
if not link then return end
local name, _, _, _, _, _, subtype = GetItemInfo(link)
return subtype == "Item Enhancement" and name:match("^Scroll of Enchant")
end
local butt1 = LibStub("tekKonfig-Button").new(f, "TOPLEFT", 4, -4)
butt1:SetFrameLevel(AuctionFrame:GetFrameLevel()+1)
butt1:SetText("Sell Chants")
butt1.tiptext = "Post all enchant scrolls in your bags as single-item auctions"
butt1:SetScript("OnClick", function(self)
for bag=0,4 do
for slot=1,GetContainerNumSlots(bag) do
local link = GetContainerItemLink(bag, slot)
if IsEnchantScroll(link) then
local price = GetPrice(link, 1)
if price then tekauc:PostBatch(ids[link], price, 1) end
end
end
end
end)
local butt2 = LibStub("tekKonfig-Button").new(f, "LEFT", butt1, "RIGHT")
butt2:SetFrameLevel(AuctionFrame:GetFrameLevel()+1)
butt2:SetText("Sell Glyphs")
butt2.tiptext = "Post all glyphs in your bags as single-item auctions"
butt2:SetScript("OnClick", function(self)
for bag=0,4 do
for slot=1,GetContainerNumSlots(bag) do
local link = GetContainerItemLink(bag, slot)
if link and select(6, GetItemInfo(link)) == "Glyph" then
local price = GetPrice(link, 1)
if price then tekauc:PostBatch(ids[link], price, 1) end
end
end
end
end)
local butt5 = LibStub("tekKonfig-Button").new(f, "LEFT", butt2, "RIGHT")
butt5:SetFrameLevel(AuctionFrame:GetFrameLevel()+1)
butt5:SetText("Sell Gems")
butt5.tiptext = "Post all cut gems in your bags"
butt5:SetScript("OnClick", function(self)
for bag=0,4 do
for slot=1,GetContainerNumSlots(bag) do
local link = GetContainerItemLink(bag, slot)
if link and select(6, GetItemInfo(link)) == "Gem" and not blist:match(ids[link]) then
local price = GetPrice(link, 1)
if price then tekauc:PostBatch(ids[link], price, 1) end
end
end
end
end)