Thread Tools Display Modes
Prev Previous Post   Next Post Next
04-16-24, 05:50 AM   #1
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 115
Buy from a vendor the first time

Hi all. There is a code that currently works as follows: When contacting a vendor, he buys the specified items. In this case, you need to contact the vendor twice (he does not buy the goods the first time).

Lua Code:
  1. local addonName, addon = ...
  2. local frameName = "ZAMESTOTV_BUY299"
  3. if not _G[frameName] then
  4.     _G[frameName] = CreateFrame("Frame")
  5.     _G[frameName]:RegisterEvent("MERCHANT_SHOW")
  6. end
  7.  
  8. local function Set(list)
  9.     local set = {}
  10.     for _, l in ipairs(list) do set[l] = true end
  11.     return set
  12. end
  13.  
  14. local vendors = {
  15.     ['Arvik'] = {['Skrog Liver Oil'] = true, },
  16.     ['Bukarakikk'] = {['Hunk o\' Blubber'] = true, },
  17.     ['Erugosa'] = {['Exquisite Ohn\'ahran Potato'] = true, ['Flaky Pastry Dough'] = true, ['Dark Thaldraszian Cocoa Powder'] = true, ['Four-Cheese Blend'] = true, },
  18.     ['Gracus'] = {['Greenberry'] = true, ['Fresh Dragon Fruit'] = true, ['Juicy Bushfruit'] = true, ['Dried Coldsnap Sagittate'] = true, },
  19.     ['Hanu'] = {['Eye of Bass'] = true, },
  20.     ['Head Chef Stacks'] = {['Rations: Scorpid Surprise'] = true, ['Rations: Undermine Clam Chowder'] = true, ['Rations: Westfall Stew'] = true, ['Rations: Dragonbreath Chili'] = true, },
  21.     ['Jinkutuk'] = {['Salted Fish Scraps'] = true, },
  22.     ['Junnik'] = {['Thousandbite Piranha Collar'] = true, },
  23.     ['Elder Nappa'] = {['Nappa\'s Famous Tea'] = true, },
  24.     ['Norukk'] = {['Norukk\'s "All-Purpose" Fish Powder'] = true, },
  25.     ['Qariin Dotur'] = {['Seven Spices Bruffalon'] = true, ['Dragonflame Argali'] = true, ['Thrice-Charred Mammoth Ribs'] = true, ['"Volcano" Duck'] = true, },
  26.     ['Patchu'] = {['Lunker Bits'] = true, },
  27.     ['Rokkutuk'] = {['Deepsquid Ink'] = true, },
  28.     ['Tattukiaka'] = {['Fermented Mackerel Paste'] = true, },
  29.     ['Tikukk'] = {['Island Crab Jerky'] = true, },
  30.     ['Tuukanit'] = {['Piping-Hot Orca Milk'] = true, },
  31. }  
  32.  
  33. local function p(msg)
  34.     print("[ZAMESTOTV: Community Feast] " .. msg)
  35. end
  36.  
  37. local frame = _G[frameName]
  38. frame:SetScript("OnEvent", function(self, event, ...)
  39.     if IsShiftKeyDown() then return end
  40.    
  41.     local targetName = UnitName("target")
  42.     if not targetName then return end
  43.     local vendor = vendors[targetName]
  44.     if not vendor then return end
  45.  
  46.     local numItems = GetMerchantNumItems()
  47.     for i = numItems, 1, -1 do
  48.         local name = GetMerchantItemInfo(i)
  49.         if vendor[name] then
  50.             p("Buying: " .. name)
  51.             pcall(function() BuyMerchantItem(i) end)
  52.         end
  53.     end
  54. end)

As planned: Purchasing items when first contacting the vendor.
  Reply With Quote
 

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Buy from a vendor the first time


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off