1
0
Fork 0

Modules: Fixed AH purchasing; now goes bottom up and also clears on API search query instead of update event

This commit is contained in:
pigmonkey 2011-06-11 23:46:05 -04:00
parent c59d191263
commit 53701ad4df

View file

@ -1,5 +1,5 @@
local core = LibStub("AceAddon-3.0"):GetAddon("AllTheLittleThings") local core = LibStub("AceAddon-3.0"):GetAddon("AllTheLittleThings")
local mod = core:NewModule("Macros", "AceTimer-3.0", "AceEvent-3.0") local mod = core:NewModule("Macros", "AceTimer-3.0", "AceEvent-3.0", "AceHook-3.0")
local db local db
local defaults = { local defaults = {
@ -21,7 +21,7 @@ function mod:OnInitialize()
self:RegisterSlashCommand("Countdown", "cd", "countdown") self:RegisterSlashCommand("Countdown", "cd", "countdown")
self:RegisterSlashCommand("RosterCheck", "rc", "rostercheck") self:RegisterSlashCommand("RosterCheck", "rc", "rostercheck")
self:RegisterSlashCommand("AuctionHouseBuyout", "ahbo") self:RegisterSlashCommand("AuctionHouseBuyout", "ahbo")
self:RegisterEvent("AUCTION_ITEM_LIST_UPDATE") self:Hook("QueryAuctionItems", true)
end end
function mod:DisbandRaid() function mod:DisbandRaid()
@ -172,11 +172,11 @@ function mod:AuctionHouseBuyout()
local selected = GetSelectedAuctionItem("list") local selected = GetSelectedAuctionItem("list")
if selected>0 then if selected>0 then
local name,_,count,_,_,_,_,_,price = GetAuctionItemInfo("list", selected) local name,_,count,_,_,_,_,_,price = GetAuctionItemInfo("list", selected)
for j=1,50 do for j=50,1,-1 do
local t_name,_,t_count,_,_,_,_,_,t_price = GetAuctionItemInfo("list", j) if not bought[j] and selected ~= j then
-- must be same item name and equal or less price per unit local t_name,_,t_count,_,_,_,_,_,t_price = GetAuctionItemInfo("list", j)
if (t_name == name) and (t_price>0) and (t_price/t_count <= price/count) then -- must be same item name and equal or less price per unit
if not bought[j] and selected ~= j then if (t_name == name) and (t_price>0) and (t_price/t_count <= price/count) then
--self:Print("Buying",j,"at",t_price) --self:Print("Buying",j,"at",t_price)
PlaceAuctionBid("list", j, t_price) PlaceAuctionBid("list", j, t_price)
bought[j] = true bought[j] = true
@ -191,7 +191,7 @@ function mod:AuctionHouseBuyout()
end end
end end
function mod:AUCTION_ITEM_LIST_UPDATE() function mod:QueryAuctionItems()
wipe(bought) wipe(bought)
end end