Thread Tools Display Modes
04-18-24, 10:04 AM   #21
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
Excellent.

It is a learning curve. I've been writing addons since 2008 I think, maybe earlier but there are still areas I haven't even looked at ( including the stuff I needed to write this test addon rofl ) and with Blizzard changing stuff most expansions, it's time to learn again rofl.

But, seriously, those links I posted before you will find useful. At least bookmark the wiki.gg link I posted as even us veterans visit it when we need to rofl.
__________________


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
04-18-24, 09:27 PM   #22
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 113
I add all the topics with my questions to my browser bookmarks. This is a very good forum, with helpful people.
  Reply With Quote
04-25-24, 12:21 AM   #23
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 113
Originally Posted by Xrystal View Post
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)
Hello. During quick testing, I noticed that when purchasing items, it says “Failed to purchase” on all items.

Option 1) - remove these inscriptions.
Option 2) - so that the inscription is correct.

Any option suits me.
  Reply With Quote
04-25-24, 10:34 AM   #24
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
It would depend on the reason for failing.

Are the correct items per vendor set up correctly ?
Did you investigate and see which ones it didn't purchase ?
Did you check to see if there was a miss spell somewhere that meant it couldn't find the item to purchase ?
Did you run out of currency to purchase the item ?

Finding out why it happened will put you in the direction of identifying what needs to be done. It could be as simple as removing a non existent item, correct a spelling mistake or coding a stop or skip when the required currency is no longer availablw.
__________________


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
04-26-24, 01:47 AM   #25
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 113
Originally Posted by Xrystal View Post
It would depend on the reason for failing.

Are the correct items per vendor set up correctly ?
Did you investigate and see which ones it didn't purchase ?
Did you check to see if there was a miss spell somewhere that meant it couldn't find the item to purchase ?
Did you run out of currency to purchase the item ?

Finding out why it happened will put you in the direction of identifying what needs to be done. It could be as simple as removing a non existent item, correct a spelling mistake or coding a stop or skip when the required currency is no longer availablw.
It’s just that the merchant has only 1 item available for sale (the rest will be blocked and not available)
For example
Lua Code:
  1. ['Head Chef Stacks'] = {['Rations: Scorpid Surprise'] = true, ['Rations: Undermine Clam Chowder'] = true, ['Rations: Westfall Stew'] = true, ['Rations: Dragonbreath Chili'] = true, },
In this example, the merchant has all the items in stock, but can only buy 1.
  Reply With Quote
04-26-24, 02:19 AM   #26
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
It should already be ignoring the other items.

Also, looking at your line for BuyMerchantItem - the wiki page doesn't say it returns a value, so it will always be false I suspect. This could be the cause of your problem
https://warcraft.wiki.gg/wiki/API_BuyMerchantItem

Lua Code:
  1. local function BuyItemsFromVendor(vendorName)
  2.     --  Create a table of items for this vendor's name
  3.     local vendor = vendors[vendorName]  
  4.     -- No items ?  Then don't bother with the rest of the work
  5.     if not vendor then return end              
  6.  
  7.     local numItems = GetMerchantNumItems()
  8.     for i = numItems, 1, -1 do
  9.         local name = GetMerchantItemInfo(i)
  10.         -- Is this item in the list of items for this vendor we want to buy ?
  11.         if vendor[name] then                      
  12.             local success = BuyMerchantItem(i)
  13.             if success then
  14.                 PrintMessage("Purchased: " .. name)
  15.             else
  16.                 PrintMessage("Failed to purchase: " .. name)
  17.             end
  18.         end
  19.     end
  20. end
__________________


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

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