diff --git a/Seller.lua b/Seller.lua index e20543b..48728d6 100644 --- a/Seller.lua +++ b/Seller.lua @@ -3,28 +3,35 @@ local Seller = Seller or {}; Seller.frame = CreateFrame("Frame", "Seller", UIParent); Seller.frame:SetFrameStrata("BACKGROUND"); -Seller.frame:SetScript("OnEvent", - function (self, event, ...) - local sum = 0; +function Seller:sellItem (bag, slot, item) + local price = select(11, GetItemInfo(item)); + local quantity, _, _, _, _, _, _, noValue = select(2, GetContainerItemInfo(bag, slot)); - for bag = 0, 4 do - for slot = 1, GetContainerNumSlots(bag) do - local item = GetContainerItemID(bag, slot); + if (not noValue) then + UseContainerItem(bag, slot); + end + + return price * quantity; +end + +function Seller:sellAllGrays(event, ...) + local sum = 0; - if (item and 0 == select(3, GetItemInfo(item))) then - local price = select(11, GetItemInfo(item)); - local quantity = select(2, GetContainerItemInfo(bag, slot)); + for bag = 0, 4 do + for slot = 1, GetContainerNumSlots(bag) do + local item = GetContainerItemID(bag, slot); - sum = sum + price * quantity; - UseContainerItem(bag, slot); - end + if (item and 0 == select(3, GetItemInfo(item))) then + sum = sum + Seller:sellItem(bag, slot, item); end end + end - if (sum ~= 0) then - print("Selling gray items for", GetCoinTextureString(sum)); - end + if (sum ~= 0) then + print("Selling gray items for", GetCoinTextureString(sum)); end -); +end + +Seller.frame:SetScript("OnEvent", Seller.sellAllGrays); Seller.frame:RegisterEvent("MERCHANT_SHOW"); \ No newline at end of file diff --git a/Seller.toc b/Seller.toc index 2d89e4b..4f246cb 100644 --- a/Seller.toc +++ b/Seller.toc @@ -1,7 +1,7 @@ -## Interface: 70100 +## Interface: 80100 ## Title: Seller ## Notes: Sells your gray items when you speak to a vendor. ## Author: Akcent -## Version: 1.0.4 +## Version: 1.0.5 Seller.lua