From 338fb9cb65725e860f3eeaec1e26fd5236ae31f3 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Sat, 26 Sep 2015 13:23:08 +0200 Subject: [PATCH 1/2] small bugfix, also no longer undercutting unless 0 stacks are your own --- sell.lua | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/sell.lua b/sell.lua index 7e2550a..4e31b60 100644 --- a/sell.lua +++ b/sell.lua @@ -82,29 +82,32 @@ function Aux_AuctionsCreateAuctionButton_OnClick() MoneyInputFrame_GetCopper(BuyoutPrice), currentAuction.stackCount, function(posted) - local entry - for _, existingEntry in ipairs(auxSellEntries[name]) do - if existingEntry.buyoutPrice == buyoutPrice and existingEntry.stackSize == stackSize then - existingEntry.count = existingEntry.count + posted - existingEntry.numYours = existingEntry.numYours + posted - existingEntry.maxTimeLeft = max(existingEntry.maxTimeLeft, duration) - entry = existingEntry + if posted > 0 then + auxSellEntries[name] = auxSellEntries[name] or { created=GetTime() } + local entry + for _, existingEntry in ipairs(auxSellEntries[name]) do + if existingEntry.buyoutPrice == buyoutPrice and existingEntry.stackSize == stackSize then + existingEntry.count = existingEntry.count + posted + existingEntry.numYours = existingEntry.numYours + posted + existingEntry.maxTimeLeft = max(existingEntry.maxTimeLeft, duration) + entry = existingEntry + end end + if not entry then + entry = { + stackSize = stackSize, + buyoutPrice = buyoutPrice, + itemPrice = buyoutPrice / stackSize, + maxTimeLeft = duration, + count = posted, + numYours = posted, + } + tinsert(auxSellEntries[name], entry) + table.sort(auxSellEntries[name], function(a,b) return a.itemPrice < b.itemPrice end) + end + auxSellEntries[name].selected = entry + Aux_UpdateRecommendation() end - if not entry then - entry = { - stackSize = stackSize, - buyoutPrice = buyoutPrice, - itemPrice = buyoutPrice / stackSize, - maxTimeLeft = duration, - count = posted, - numYours = posted, - } - tinsert(auxSellEntries[name], entry) - table.sort(auxSellEntries[name], function(a,b) return a.itemPrice < b.itemPrice end) - end - auxSellEntries[name].selected = entry - Aux_UpdateRecommendation() end ) else @@ -183,7 +186,7 @@ function Aux_UpdateRecommendation() local newBuyoutPrice = auxSellEntries[currentAuction.name].selected.itemPrice * currentAuction.stackSize - if auxSellEntries[currentAuction.name].selected.numYours < auxSellEntries[currentAuction.name].selected.count then + if auxSellEntries[currentAuction.name].selected.numYours == 0 then newBuyoutPrice = undercut(newBuyoutPrice) end From b3bf6579b1a74897c768e6b287806acfe7897f0e Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Sat, 26 Sep 2015 13:35:56 +0200 Subject: [PATCH 2/2] another small bugfix --- sell.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sell.lua b/sell.lua index 4e31b60..5fbb183 100644 --- a/sell.lua +++ b/sell.lua @@ -82,7 +82,7 @@ function Aux_AuctionsCreateAuctionButton_OnClick() MoneyInputFrame_GetCopper(BuyoutPrice), currentAuction.stackCount, function(posted) - if posted > 0 then + if posted > 0 and buyoutPrice > 0 then auxSellEntries[name] = auxSellEntries[name] or { created=GetTime() } local entry for _, existingEntry in ipairs(auxSellEntries[name]) do