View Single Post
10-12-15, 03:25 PM   #11
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
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:
  1. local EventFrame=CreateFrame("Frame");
  2. EventFrame:RegisterEvent("MERCHANT_SHOW");
  3. EventFrame:RegisterEvent("MERCHANT_CLOSED");
  4. EventFrame:SetScript("OnEvent",function(self,event)
  5.     if event=="MERCHANT_SHOW" then
  6.         self:RegisterEvent("BAG_UPDATE_DELAYED");
  7.     elseif event=="MERCHANT_CLOSED" then
  8.         self:UnregisterEvent("BAG_UPDATE_DELAYED");
  9.         return
  10.     end
  11.  
  12.     local rescan=false;
  13.     ClearCursor();
  14.     for i=0,NUM_BAG_SLOTS do
  15.         for j=1,GetContainerNumSlots(i) do
  16.             local _,_,_,quality,_,_,_,_,novalue=GetContainerItemInfo(i,j);
  17.             if quality==LE_ITEM_QUALITY_POOR and not novalue then
  18.                 rescan=true;
  19.                 PickupContainerItem(i,j);
  20.                 PickupMerchantItem();
  21.             end
  22.         end
  23.     end
  24.  
  25.     if not rescan then self:UnregisterEvent("BAG_UPDATE_DELAYED"); end
  26. end);
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote