/Tukui/modules/loot/merchant.lua
Lua | 88 lines | 84 code | 3 blank | 1 comment | 18 complexity | 9b99fcb51e23ac53aa04142c78aaef82 MD5 | raw file
1local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales 2 3local filter = { 4 [6289] = true, -- Raw Longjaw Mud Snapper 5 [6291] = true, -- Raw Brilliant Smallfish 6 [6308] = true, -- Raw Bristle Whisker Catfish 7 [6309] = true, -- 17 Pound Catfish 8 [6310] = true, -- 19 Pound Catfish 9 [41808] = true, -- Bonescale Snapper 10 [42336] = true, -- Bloodstone Band 11 [42337] = true, -- Sun Rock Ring 12 [43244] = true, -- Crystal Citrine Necklace 13 [43571] = true, -- Sewer Carp 14 [43572] = true, -- Magic Eater 15 [53062] = true, -- Sharptooth 16 [53069] = true, -- Murglesnout 17} 18 19local f = CreateFrame("Frame") 20f:SetScript("OnEvent", function() 21 if C["merchant"].sellgrays or C["merchant"].sellmisc then 22 local c = 0 23 for b=0,4 do 24 for s=1,GetContainerNumSlots(b) do 25 local l,lid = GetContainerItemLink(b, s), GetContainerItemID(b, s) 26 if l and lid then 27 local p = select(11, GetItemInfo(l))*select(2, GetContainerItemInfo(b, s)) 28 if C["merchant"].sellgrays and select(3, GetItemInfo(l))==0 and p > 0 then 29 UseContainerItem(b, s) 30 PickupMerchantItem() 31 c = c+p 32 end 33 if C["merchant"].sellmisc and filter[ lid ] then 34 UseContainerItem(b, s) 35 PickupMerchantItem() 36 c = c+p 37 end 38 end 39 end 40 end 41 if c>0 then 42 local g, s, c = math.floor(c/10000) or 0, math.floor((c%10000)/100) or 0, c%100 43 DEFAULT_CHAT_FRAME:AddMessage(L.merchant_trashsell.." |cffffffff"..g..L.goldabbrev.." |cffffffff"..s..L.silverabbrev.." |cffffffff"..c..L.copperabbrev..".",255,255,0) 44 end 45 end 46 if not IsShiftKeyDown() then 47 if CanMerchantRepair() and C["merchant"].autorepair then 48 local cost, possible = GetRepairAllCost() 49 if C["merchant"].guildrepair then 50 if (IsInGuild()) and (CanGuildBankRepair()) then 51 if cost <= GetGuildBankWithdrawMoney() then 52 guildRepairFlag = 1 53 end 54 end 55 end 56 if cost>0 then 57 if possible then 58 local c = cost%100 59 local s = math.floor((cost%10000)/100) 60 local g = math.floor(cost/10000) 61 if guildRepairFlag == 1 then 62 RepairAllItems(1) 63 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00Repaired using guild bank.|r") 64 else 65 RepairAllItems() 66 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00Repaired using personal funds.|r") 67 end 68 DEFAULT_CHAT_FRAME:AddMessage(L.merchant_repaircost.." |cffffffff"..g..L.goldabbrev.." |cffffffff"..s..L.silverabbrev.." |cffffffff"..c..L.copperabbrev..".",255,255,0) 69 else 70 DEFAULT_CHAT_FRAME:AddMessage(L.merchant_repairnomoney,255,0,0) 71 end 72 end 73 end 74 end 75end) 76f:RegisterEvent("MERCHANT_SHOW") 77 78-- buy max number value with alt 79local savedMerchantItemButton_OnModifiedClick = MerchantItemButton_OnModifiedClick 80function MerchantItemButton_OnModifiedClick(self, ...) 81 if ( IsAltKeyDown() ) then 82 local maxStack = select(8, GetItemInfo(GetMerchantItemLink(self:GetID()))) 83 if ( maxStack and maxStack > 1 ) then 84 BuyMerchantItem(self:GetID(), GetMerchantItemMaxStack(self:GetID())) 85 end 86 end 87 savedMerchantItemButton_OnModifiedClick(self, ...) 88end