Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Copyright (c) 2019 "Cowboy" Ben Alman
- -- Licensed under the MIT license
- local frameName = "CB_VENDOR_AUTO_BUY_FRAME"
- if not _G[frameName] then
- _G[frameName] = CreateFrame("Frame")
- _G[frameName]:RegisterEvent("MERCHANT_SHOW")
- end
- local function Set(list)
- local set = {}
- for _, l in ipairs(list) do set[l] = true end
- return set
- end
- local vendors = {
- ["Qia"] = Set {
- "Pattern: Runecloth Gloves",
- "Pattern: Runecloth Bag"
- }
- }
- local function p(msg)
- print("[CB_VendorAutoBuy] " .. msg)
- end
- local frame = _G[frameName]
- frame:SetScript("OnEvent", function(self, event, ...)
- if IsShiftKeyDown() then return end
- local targetName = UnitName("target")
- if not targetName then return end
- local vendor = vendors[targetName]
- if not vendor then return end
- local numItems = GetMerchantNumItems()
- for i = numItems, 1, -1 do
- local name = GetMerchantItemInfo(i)
- if vendor[name] then
- p("Buying: " .. name)
- pcall(function() BuyMerchantItem(i) end)
- end
- end
- local count = 0
- frame:SetScript("OnUpdate", function(self)
- count = count + 1
- if count > 10 then
- CloseMerchant()
- frame:SetScript("OnUpdate", nil)
- end
- end)
- end)
- p("loaded!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement