diff --git a/src/INEED.lua b/src/INEED.lua index 2876241..821d8b9 100644 --- a/src/INEED.lua +++ b/src/INEED.lua @@ -55,6 +55,7 @@ function INEED.OnLoad() INEED_Frame:RegisterEvent("ADDON_LOADED") INEED_Frame:RegisterEvent("BAG_UPDATE") INEED_Frame:RegisterEvent("MERCHANT_SHOW") + INEED_Frame:RegisterEvent("MERCHANT_CLOSED") INEED_Frame:RegisterEvent("MAIL_SHOW") INEED_Frame:RegisterEvent("PLAYER_ENTERING_WORLD") INEED_Frame:RegisterEvent("CURRENCY_DISPLAY_UPDATE") @@ -372,6 +373,7 @@ end function INEED.MERCHANT_SHOW() -- Event handler. Autopurchase --local numItems = GetMerchantNumItems() + INEED.isMerchantOpen = true local purchaseAmount = 0 local msgSent = false for i = 0, GetMerchantNumItems() do -- Go through the items for sale @@ -456,6 +458,9 @@ function INEED.MERCHANT_SHOW() BuyMerchantItem(index {, quantity}); ]]-- end +function INEED.MERCHANT_CLOSED() + INEED.isMerchantOpen = nil +end function INEED.PLAYER_MONEY() -- PLAYER_MONEY has changed if INEED_account.percent then -- look to see if need to add to balance @@ -721,6 +726,9 @@ function INEED.addItem( itemLink, quantity ) INEED.clearData() end end + if INEED.isMerchantOpen then + INEED.MERCHANT_SHOW() -- Allow a newly added item to trigger a purchase with + end return itemLink -- return early end local enchantID = INEED.getEnchantIdFromLink( itemLink )