This is a more automated version of the script I use on slash command. It uses
BAG_UPDATE_DELAYED to retry selling items as it fires once after all
BAG_UPDATE events are done.
Lua Code:
local EventFrame=CreateFrame("Frame");
EventFrame:RegisterEvent("MERCHANT_SHOW");
EventFrame:RegisterEvent("MERCHANT_CLOSED");
EventFrame:SetScript("OnEvent",function(self,event)
if event=="MERCHANT_SHOW" then
self:RegisterEvent("BAG_UPDATE_DELAYED");
elseif event=="MERCHANT_CLOSED" then
self:UnregisterEvent("BAG_UPDATE_DELAYED");
return
end
local rescan=false;
ClearCursor();
for i=0,NUM_BAG_SLOTS do
for j=1,GetContainerNumSlots(i) do
local _,_,_,quality,_,_,_,_,novalue=GetContainerItemInfo(i,j);
if quality==LE_ITEM_QUALITY_POOR and not novalue then
rescan=true;
PickupContainerItem(i,j);
PickupMerchantItem();
end
end
end
if not rescan then self:UnregisterEvent("BAG_UPDATE_DELAYED"); end
end);