From 53701ad4df4136aaa15a6776c8c035ceeddab817 Mon Sep 17 00:00:00 2001 From: pigmonkey Date: Sat, 11 Jun 2011 23:46:05 -0400 Subject: [PATCH] Modules: Fixed AH purchasing; now goes bottom up and also clears on API search query instead of update event --- modules/macros.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/macros.lua b/modules/macros.lua index 7b305a9..5fbdb47 100644 --- a/modules/macros.lua +++ b/modules/macros.lua @@ -1,5 +1,5 @@ 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 defaults = { @@ -21,7 +21,7 @@ function mod:OnInitialize() self:RegisterSlashCommand("Countdown", "cd", "countdown") self:RegisterSlashCommand("RosterCheck", "rc", "rostercheck") self:RegisterSlashCommand("AuctionHouseBuyout", "ahbo") - self:RegisterEvent("AUCTION_ITEM_LIST_UPDATE") + self:Hook("QueryAuctionItems", true) end function mod:DisbandRaid() @@ -172,11 +172,11 @@ function mod:AuctionHouseBuyout() local selected = GetSelectedAuctionItem("list") if selected>0 then local name,_,count,_,_,_,_,_,price = GetAuctionItemInfo("list", selected) - for j=1,50 do - local t_name,_,t_count,_,_,_,_,_,t_price = GetAuctionItemInfo("list", j) - -- must be same item name and equal or less price per unit - if (t_name == name) and (t_price>0) and (t_price/t_count <= price/count) then - if not bought[j] and selected ~= j then + for j=50,1,-1 do + if not bought[j] and selected ~= j then + local t_name,_,t_count,_,_,_,_,_,t_price = GetAuctionItemInfo("list", j) + -- must be same item name and equal or less price per unit + if (t_name == name) and (t_price>0) and (t_price/t_count <= price/count) then --self:Print("Buying",j,"at",t_price) PlaceAuctionBid("list", j, t_price) bought[j] = true @@ -191,7 +191,7 @@ function mod:AuctionHouseBuyout() end end -function mod:AUCTION_ITEM_LIST_UPDATE() +function mod:QueryAuctionItems() wipe(bought) end