View Single Post
04-16-24, 07:29 AM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,950
Not quite - I wasn't sure what the following was for so my updated version doesn't have it in
Lua Code:
  1. if IsShiftKeyDown() then return end


Give this a go. As a reminder, event watching only frames technically don't need to be named.

I have clearly separated the sections of the code you posted so that it makes it easier to see which items you can put in separate files if and when you need to. At the moment it's small enough in the one file.


Lua Code:
  1. local addonName, addon = ...
  2.  
  3. ---------------------------
  4. -- Vendor Related Set up --
  5. ---------------------------
  6.  
  7. local vendors = {
  8.     ['Arvik'] = {['Skrog Liver Oil'] = true, },
  9.     ['Bukarakikk'] = {['Hunk o\' Blubber'] = true, },
  10.     ['Erugosa'] = {['Exquisite Ohn\'ahran Potato'] = true, ['Flaky Pastry Dough'] = true, ['Dark Thaldraszian Cocoa Powder'] = true, ['Four-Cheese Blend'] = true, },
  11.     ['Gracus'] = {['Greenberry'] = true, ['Fresh Dragon Fruit'] = true, ['Juicy Bushfruit'] = true, ['Dried Coldsnap Sagittate'] = true, },
  12.     ['Hanu'] = {['Eye of Bass'] = true, },
  13.     ['Head Chef Stacks'] = {['Rations: Scorpid Surprise'] = true, ['Rations: Undermine Clam Chowder'] = true, ['Rations: Westfall Stew'] = true, ['Rations: Dragonbreath Chili'] = true, },
  14.     ['Jinkutuk'] = {['Salted Fish Scraps'] = true, },
  15.     ['Junnik'] = {['Thousandbite Piranha Collar'] = true, },
  16.     ['Elder Nappa'] = {['Nappa\'s Famous Tea'] = true, },
  17.     ['Norukk'] = {['Norukk\'s "All-Purpose" Fish Powder'] = true, },
  18.     ['Qariin Dotur'] = {['Seven Spices Bruffalon'] = true, ['Dragonflame Argali'] = true, ['Thrice-Charred Mammoth Ribs'] = true, ['"Volcano" Duck'] = true, },
  19.     ['Patchu'] = {['Lunker Bits'] = true, },
  20.     ['Rokkutuk'] = {['Deepsquid Ink'] = true, },
  21.     ['Tattukiaka'] = {['Fermented Mackerel Paste'] = true, },
  22.     ['Tikukk'] = {['Island Crab Jerky'] = true, },
  23.     ['Tuukanit'] = {['Piping-Hot Orca Milk'] = true, },
  24. }  
  25.  
  26. -----------------------
  27. -- Utility Functions --
  28. -----------------------
  29.  
  30. local function PrintMessage(msg)
  31.     print("[ZAMESTOTV: Community Feast] " .. msg)
  32. end
  33.  
  34. --------------------------------
  35. -- The actual purchasing part --
  36. --------------------------------
  37.  
  38. local function BuyItemsFromVendor(vendorName)
  39.     local vendor = vendors[vendorName]
  40.     if not vendor then return end
  41.  
  42.     local numItems = GetMerchantNumItems()
  43.     for i = numItems, 1, -1 do
  44.         local name = GetMerchantItemInfo(i)
  45.         if vendor[name] then
  46.             local success = BuyMerchantItem(i)
  47.             if success then
  48.                 PrintMessage("Purchased: " .. name)
  49.             else
  50.                 PrintMessage("Failed to purchase: " .. name)
  51.             end
  52.         end
  53.     end
  54. end
  55.  
  56. ----------------------
  57. -- Event Management --
  58. ----------------------
  59.  
  60. local function AutoPurchaseSelectedItems()
  61.     local targetName = UnitName("target")
  62.     if not targetName then return end
  63.    
  64.     BuyItemsFromVendor(targetName)
  65. end
  66.  
  67. local function OnEvent(self, event, ...)
  68.     if event == "MERCHANT_SHOW" then
  69.         self:RegisterEvent("MERCHANT_UPDATE")
  70.     elseif event == "MERCHANT_UPDATE" then
  71.         self:UnregisterEvent(event)
  72.         AutoPurchaseSelectedItems()
  73.     end
  74. end
  75.  
  76. local eventWatcher = CreateFrame("Frame")
  77. eventWatcher:RegisterEvent("MERCHANT_SHOW")
  78. eventWatcher:SetScript("OnEvent", OnEvent)
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote