From 33a29a36310997860d66d01ae7da6df5acf49606 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Mon, 21 Mar 2016 14:25:00 +0100 Subject: [PATCH] perfected price scanning --- cache.lua | 18 ++++++++++++++---- core.lua | 2 +- info.lua | 16 ++++++++++------ 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/cache.lua b/cache.lua index 4d5afb4..3af1216 100644 --- a/cache.lua +++ b/cache.lua @@ -15,9 +15,19 @@ function public.on_load() private.scan_wdb() Aux.control.event_listener('MERCHANT_SHOW', private.scan_merchant).start() Aux.control.event_listener('MERCHANT_UPDATE', private.scan_merchant).start() --- Aux.control.event_listener('NEW_AUCTION_UPDATE', function() - -- -- TODO GetAuctionSellItemInfo() - -- -- end).start() + Aux.control.event_listener('BAG_UPDATE', function() + if MerchantFrame:IsVisible() then + private.scan_merchant() + end + end).start() + Aux.control.event_listener('NEW_AUCTION_UPDATE', function() + local info = Aux.info.auction_sell_item() + if info then + if Aux.cache.item_id(info.name) then + aux_merchant_sell[Aux.cache.item_id(info.name)] = info.vendor_price / info.aux_quantity + end + end + end).start() end function public.merchant_info(item_id) @@ -63,7 +73,7 @@ function private.scan_merchant() local merchant_item_count = GetMerchantNumItems() for i=1,merchant_item_count do local link = GetMerchantItemLink(i) - if link then -- TODO somehow try again when the item is in the wdb? + if link then local item_id = Aux.info.parse_hyperlink(link) local _, _, price, count, stock = GetMerchantItemInfo(i) local new_unit_price, new_limited = price / count, stock >= 0 diff --git a/core.lua b/core.lua index 040354d..11be4ca 100644 --- a/core.lua +++ b/core.lua @@ -1,5 +1,5 @@ Aux = { - version = '2.9.6', + version = '2.9.7', blizzard_ui_shown = false, orig = {}, } diff --git a/info.lua b/info.lua index e18dcd0..1ea8a16 100644 --- a/info.lua +++ b/info.lua @@ -80,23 +80,27 @@ function public.container_item(bag, slot) end function public.auction_sell_item() - local name, texture, stack_size, quality, usable, vendor_price = GetAuctionSellItemInfo() + local name, texture, count, quality, usable, vendor_price = GetAuctionSellItemInfo() if name then - local unit_vendor_price = vendor_price / stack_size + local unit_vendor_price = vendor_price / count local tooltip = public.tooltip(function(tt) tt:SetAuctionSellItem() end) - return { + local charges = private.item_charges(tooltip) + local aux_quantity = charges or count + + return { name = name, texture = texture, quality = quality, - - stack_size = stack_size, + aux_quantity = aux_quantity, + stack_size = count, usable = usable, + vendor_price = vendor_price, unit_vendor_price = unit_vendor_price, tooltip = tooltip, - charges = private.item_charges(tooltip), + charges = charges, } end end