From ea329143b650b9e5889d94780f8fbc809199ff87 Mon Sep 17 00:00:00 2001 From: opussf Date: Wed, 8 Nov 2023 22:49:40 -0800 Subject: [PATCH] Immediately buys from current merchant if you add something they sell A world without string is chaos. --- src/INEED.lua | 8 ++++++++ 1 file changed, 8 insertions(+) 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 )