Thread Tools Display Modes
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: 113
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
04-16-24, 06:43 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
It might be because it is processing things a bit too soon.

You could see if using the MERCHANT_UPDATE event ( at least the first time around ) will be the best time to do any semi automatic transactions.

Looking at the MerchantFrame Blizzard code ( https://github.com/Gethe/wow-ui-sour...chantFrame.lua ) The updating of the merchant frame doesn't occur until the end of the Merchant_Show function. So it is possible that the following is happening.



Lua Code:
  1. function MerchantFrame_MerchantShow()
  2.     ShowUIPanel(MerchantFrame);
  3.  
  4. >>>> MERCHANT_SHOW triggers here perhaps
  5.  
  6.     if ( not MerchantFrame:IsShown() ) then
  7.         CloseMerchant();
  8.         return;
  9.     end
  10.     MerchantFrame.page = 1;
  11.     MerchantFrame_UpdateCurrencies();
  12.     MerchantFrame_Update();
  13.  
  14. >>>> MERCHANT_UPDATE triggers here perhaps
  15.  
  16. end

Depending on how often MERCHANT_UPDATE triggers, you might need to UnRegister it when it first triggers and have registering it happen when the MERCHANT_SHOW event triggers.


For example:
Lua Code:
  1. local addonName, addon = ...
  2.  
  3. -- Whatever Data or Functionality that needs to be available before
  4. -- It is accessed in AutoPurchaseSelectedItems function
  5. -- Either in this file or in a file listed earlier in the toc file
  6.  
  7. local function AutoPurchaseSelectedItems()
  8.     -- Whatever Buying from Merchant processing you wanted to do
  9. end
  10.  
  11. local function OnEvent(self,event,...)
  12.     if event == "MERCHANT_SHOW" then
  13.         self:RegisterEvent("MERCHANT_UPDATE")
  14.     elseif event == "MERCHANT_UPDATE" then
  15.         self:UnregisterEvent(event)
  16.         AutoPurchaseSelectedItems()
  17.     end
  18. end
  19.  
  20. local eventWatcher = CreateFrame("Frame")
  21. eventWatcher:RegisterEvent("MERCHANT_SHOW")
  22. eventWatcher:SetScript("OnEvent",OnEvent)


-- OR --

If that doesn't work. You could try hooking into the MerchantFrame_MerchantShow function to add your functionality in place.

For example:

Lua Code:
  1. local addonName, addon = ...
  2.  
  3. -- Whatever Data or Functionality that needs to be available before
  4. -- It is accessed in AutoPurchaseSelectedItems function
  5. -- Either in this file or in a file listed earlier in the toc file
  6.  
  7. local function AutoPurchaseSelectedItems()
  8.     -- Whatever Buying from Merchant processing you wanted to do
  9. end
  10.  
  11. hooksecurefunc("MerchantFrame_MerchantShow", AutoPurchaseSelectedItems)
  12.  
  13. -- What this does is execute the Blizzard MerchantShow function and immediately execute your function.  You won't have access to any variables inside the Blizzard function but it might allow you to access the Merchant in the same way you are doing already, just after it does that initial update.
__________________


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-16-24, 06:58 AM   #3
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 113
So it will be like this?
Lua Code:
  1. local addonName, addon = ...
  2.  
  3. local frameName = "ZAMESTOTV_BUY299"
  4. if not _G[frameName] then
  5.     _G[frameName] = CreateFrame("Frame")
  6.     _G[frameName]:RegisterEvent("MERCHANT_SHOW")
  7. end
  8.  
  9. local vendors = {
  10.     ['Arvik'] = {['Skrog Liver Oil'] = true, },
  11.     ['Bukarakikk'] = {['Hunk o\' Blubber'] = true, },
  12.     ['Erugosa'] = {['Exquisite Ohn\'ahran Potato'] = true, ['Flaky Pastry Dough'] = true, ['Dark Thaldraszian Cocoa Powder'] = true, ['Four-Cheese Blend'] = true, },
  13.     ['Gracus'] = {['Greenberry'] = true, ['Fresh Dragon Fruit'] = true, ['Juicy Bushfruit'] = true, ['Dried Coldsnap Sagittate'] = true, },
  14.     ['Hanu'] = {['Eye of Bass'] = true, },
  15.     ['Head Chef Stacks'] = {['Rations: Scorpid Surprise'] = true, ['Rations: Undermine Clam Chowder'] = true, ['Rations: Westfall Stew'] = true, ['Rations: Dragonbreath Chili'] = true, },
  16.     ['Jinkutuk'] = {['Salted Fish Scraps'] = true, },
  17.     ['Junnik'] = {['Thousandbite Piranha Collar'] = true, },
  18.     ['Elder Nappa'] = {['Nappa\'s Famous Tea'] = true, },
  19.     ['Norukk'] = {['Norukk\'s "All-Purpose" Fish Powder'] = true, },
  20.     ['Qariin Dotur'] = {['Seven Spices Bruffalon'] = true, ['Dragonflame Argali'] = true, ['Thrice-Charred Mammoth Ribs'] = true, ['"Volcano" Duck'] = true, },
  21.     ['Patchu'] = {['Lunker Bits'] = true, },
  22.     ['Rokkutuk'] = {['Deepsquid Ink'] = true, },
  23.     ['Tattukiaka'] = {['Fermented Mackerel Paste'] = true, },
  24.     ['Tikukk'] = {['Island Crab Jerky'] = true, },
  25.     ['Tuukanit'] = {['Piping-Hot Orca Milk'] = true, },
  26. }  
  27.  
  28. local function PrintMessage(msg)
  29.     print("[ZAMESTOTV: Community Feast] " .. msg)
  30. end
  31.  
  32. local function BuyItemsFromVendor(vendorName)
  33.     local vendor = vendors[vendorName]
  34.     if not vendor then return end
  35.  
  36.     local numItems = GetMerchantNumItems()
  37.     for i = numItems, 1, -1 do
  38.         local name = GetMerchantItemInfo(i)
  39.         if vendor[name] then
  40.             local success = BuyMerchantItem(i)
  41.             if success then
  42.                 PrintMessage("Purchased: " .. name)
  43.             else
  44.                 PrintMessage("Failed to purchase: " .. name)
  45.             end
  46.         end
  47.     end
  48. end
  49.  
  50. local frame = _G[frameName]
  51. frame:SetScript("OnEvent", function(self, event, ...)
  52.     if IsShiftKeyDown() then return end
  53.    
  54.     local targetName = UnitName("target")
  55.     if not targetName then return end
  56.    
  57.     BuyItemsFromVendor(targetName)
  58. end)
  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)
  Reply With Quote
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,935
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
04-16-24, 08:29 AM   #5
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 113
Thank you very much, now the item is purchased the first time.
  Reply With Quote
04-16-24, 06:17 PM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,327
MERCHANT_SHOW doesn't seem to be used by the retail client anymore and has been replaced with PLAYER_INTERACTION_MANAGER_FRAME_SHOW with the value of Enum.PlayerInteractionType.Merchant. This then calls MerchantFrame_MerchantShow(). MERCHANT_SHOW may still fire, but I'm getting a whiff of deprecation here.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
04-16-24, 07:10 PM   #7
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
Originally Posted by SDPhantom View Post
MERCHANT_SHOW doesn't seem to be used by the retail client anymore and has been replaced with PLAYER_INTERACTION_MANAGER_FRAME_SHOW with the value of Enum.PlayerInteractionType.Merchant. This then calls MerchantFrame_MerchantShow(). MERCHANT_SHOW may still fire, but I'm getting a whiff of deprecation here.
You could be right there.
When the time comes / or if Hubb feels like making the addon somewhat future proof now, they might be able to replace the MERCHANT_SHOW event check to that PLAYER_INTERACTION_MANAGER_FRAME_SHOW event and check for that value you mentioned before continuing on with the rest of the functionality.
__________________


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-16-24, 09:42 PM   #8
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 113
I didn't bother creating a new topic. I decided to ask a question in this thread.

How do I find out the "criteria ID" for achievements? Can this be done via https://wago.tools/, if so, how? Or are there other easier ways?

Using the example of achievements.
https://www.wowhead.com/achievement=16462/ (For example, how can you find out the “ID criterion” for "River camp to Eaglewatch Outpost")
https://www.wowhead.com/achievement=16400/ (For example, how can you find out the “ID criterion” for "Ruby Life Pools")
  Reply With Quote
04-17-24, 04:00 AM   #9
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
This is a good site to bookmark for helping with addon stuff.

https://warcraft.wiki.gg/wiki/Warcra..._customization

Gethe also keeps a copy of the Blizzard API Code available online at https://github.com/Gethe/wow-ui-source which many of us utilise to help us. You can also download your own copy following these instructions https://warcraft.wiki.gg/wiki/Viewin...interface_code.


That said, the following is where you can see the Achievement specific set of functions on the site
https://warcraft.wiki.gg/wiki/World_...I#Achievements
With this one probably being the first one I would try.
https://warcraft.wiki.gg/wiki/API_Ge...ntCriteriaInfo

You will likely have to make sure Blizzard_AchievementUI addon is loaded and available by either setting it up as a required dependency addon in your addons TOC file so that it loads before your addon and testing for https://warcraft.wiki.gg/wiki/API_C_....IsAddOnLoaded before doing any Achievement related functions.
__________________


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-17-24, 04:16 AM   #10
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 113
That's not exactly what I was looking for. Here's an example:
Achievement Glorious!, kill criterion Urobi the Walker it (criteria = 21083). But how was he recognized? And how do I find out the criterion ID?
  Reply With Quote
04-17-24, 04:44 AM   #11
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
You have an achievement you want identify the criteria IDs for ?

At the top of that GetAchievementCriteriaInfo page I linked is the set of values returned by that function
criteriaString, criteriaType, completed, quantity, reqQuantity, charName, flags, assetID, quantityString, criteriaID, eligible
= GetAchievementCriteriaInfo(achievementID, criteriaIndex [, countHidden])

It also explains how to get the criteriaIndex on the same page
criteriaIndex
number - Index of the criteria to query, ascending from 1 up to GetAchievementNumCriteria(achievementID).


So, you have the achievementID from wowhead.

After you have ensured the AchievementUI blizzard addon is loaded ( to get access to these functions ) as I explained. You can then use:

Lua Code:
  1. local achievementID = 7439 -- Glorious! Achievement ID
  2. local numCriteria = GetAchievementNumCriteria(achievementID)
  3. local criteriaString, criteriaType, completed, quantity, reqQuantity, charName, flags, assetID, quantityString, criteriaID, eligible
  4.  
  5. for criteriaIndex = 1,numCriteria do
  6.     criteriaString, criteriaType, completed, quantity, reqQuantity, charName, flags, assetID, quantityString, criteriaID, eligible
  7.    = GetAchievementCriteriaInfo(achievementID, criteriaIndex)
  8.  
  9.    -- This is where you might want to decide what to do with the information while it is available.
  10.  
  11.  
  12. end

In your addon.

Other tasks to do before doing this would be

Set up your addon's toc file so that it has a line
Lua Code:
  1. ## RequiredDeps: Blizzard_AchievementUI
This is because this is an addon that only loads up when you open the achievement window manually. If you want to access the achievement functions you have to either wait for the achievement UI to be opened by the user and watch for the appropriate event for that, or, you load the addon automatically to access the functionality.

Watch for ADDON_LOADED as usual and when your addon is loaded, immediately check and make sure that "Blizzard_AchievementUI" is loaded using
Lua Code:
  1. C_AddOns.IsAddOnLoaded("Blizzard_AchievementUI")
as I mentioned in my post. You should have learned how to do this by now with the addons you have been working on so far.

And as in the other addons you have done, you can then use the functions your addon needs at this point to do their work. The code block above is a good starting point.
__________________


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

Last edited by Xrystal : 04-17-24 at 04:54 AM.
  Reply With Quote
04-17-24, 04:53 AM   #12
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
In response to the question about wago.tools I don't know as I have never used that site.

Maybe someone that has will be able to answer that question.
__________________


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-17-24, 06:34 AM   #13
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 113
That is, if I understand correctly, I need to create a LUA file in which to add the achievement ID (from Wowhead). And when I open this achievement in the game, will I see the “ID criteria” for this achievement?

Lua Code:
  1. local achievementID = 7439 -- Glorious! Achievement ID
  2. local numCriteria = GetAchievementNumCriteria(achievementID)
  3. local criteriaString, criteriaType, completed, quantity, reqQuantity, charName, flags, assetID, quantityString, criteriaID, eligible
  4.  
  5. for criteriaIndex = 1,numCriteria do
  6.     criteriaString, criteriaType, completed, quantity, reqQuantity, charName, flags, assetID, quantityString, criteriaID, eligible
  7.    = GetAchievementCriteriaInfo(achievementID, criteriaIndex)
  8.  
  9.    -- This is where you might want to decide what to do with the information while it is available.
  10.  
  11.  
  12. end
  Reply With Quote
04-17-24, 07:58 AM   #14
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
It depends on what you wanted your addon to do.

The information I provided will allow you to get the information you might need. How you get that information on the screen is dependent on what you wanted. Some people adjust a Blizzard frame with added information ( I have never done that myself ), others create their own display similar to your other addons.

That for loop code block essentially cycles through the list of criteria the achievement in question might have and grabs the information for the criteria, like the name, description, etc. While in that for loop you will need to decide what to do with that information.
__________________


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-17-24, 08:05 AM   #15
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 113
I need criteria for completing the following achievements:
https://www.wowhead.com/achievement=6351/
https://www.wowhead.com/achievement=6975/
https://www.wowhead.com/achievement=6977
https://www.wowhead.com/achievement=6979/
https://www.wowhead.com/achievement=6969/
https://www.wowhead.com/achievement=6976/
https://www.wowhead.com/achievement=6978/

(I understand that this is too long a list. That’s why I want to figure it out on my own, but I don’t understand anything about it).

I know how I can add this to my addon so that it works, but I don’t know where to get the criteria (I only found criteria for rare monsters)

It will work something like this (it works with rare monsters)
Lua Code:
  1. achievement = {id = 7439, criteria = 21083},

My addon is that when you kill a rare monster or open an area on the map, it removes the hint mark from the map. Like HandyNotes Pandaria which contains not only rare monsters and treasures, but also all the achievements.

For example, I got to the "Dread Wastes" location in the "Zan'vess" area. From which the criterion for the achievement "Explore Dread Wastes" was fulfilled. It must have the ID of this execution.


I need to figure out how to view these “ID criteria” for achievements. I already know what to do with them next.

Last edited by Hubb777 : 04-17-24 at 08:15 AM.
  Reply With Quote
04-17-24, 09:23 AM   #16
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
Okay, so what I gave you will do what you want. All you need to do is utilise what I did for 1 achievement to make it work for multiple achievements.

For example:

Initialisation Stage
You could use that for loop to add to a list of achievement id, criteria id items.

Processing Stage
You could then go through the generated list of achievement/criteria ids and do what you want with them.

Here's what might work to get the first part of it working.

Lua Code:
  1. local addonName, addon = ...
  2.  
  3. -- Make sure achievements to track table exists
  4. local achievementsToMonitor = {
  5.     [6351] = {},
  6.     [6975] = {},
  7.     [6977] = {},
  8.     -- And any others you want to grab the information for
  9. }
  10.  
  11. -- Create variables for the values you are using in the loops
  12. local numCriteria, criteriaString, criteriaType, completed, quantity, reqQuantity, charName, flags, assetID, quantityString, criteriaID, eligible
  13.  
  14.  
  15. local function InitialiseMonitorTable()
  16.  
  17.     -- Go through each achievement in the monitor list
  18.     for achievementID,data in pairs(achievementsToMonitor) do
  19.  
  20.         numCriteria = GetAchievementNumCriteria(achievementID)
  21.  
  22.         -- Go through each criteria for this achievement
  23.         for criteriaIndex = 1,numCriteria do
  24.  
  25.             -- Grab the data for this criteriaIndex
  26.  
  27.             criteriaString, criteriaType, completed, quantity, reqQuantity, charName, flags, assetID, quantityString, criteriaID, eligible
  28.            = GetAchievementCriteriaInfo(achievementID, criteriaIndex)
  29.  
  30.            -- This is where you might want to decide what to do with the information while it is available.
  31.  
  32.             data.criteriaID = criteriaID
  33.             data.criteriaString = criteriaString
  34.             data.criteriaType = criteriaType
  35.             data.completed = completed
  36.             data.assetID = assetID
  37.             -- Any others you might want to store in the table
  38.  
  39.             -- I am not 100% sure that this keeps the data in the table once you store it here
  40.             -- But if not replace the data part with the following and see if that works
  41.             -- achievementsToMonitor[achievementID]
  42.  
  43.         end
  44.     end
  45. end
  46.  
  47.  
  48. local function ProcessMonitorTable()
  49. -- Do whatever code you want to do in here and call it when you want it to be called
  50. end
  51.  
  52.  
  53. -- The usual EventWatcher code block
  54. local eventWatcher = CreateFrame("Frame")
  55.  
  56. local function OnEvent(self,event,...)
  57.    
  58.     if event == "ADDON_LOADED" then
  59.         local addonLoaded = ...
  60.         local okayToContinue = okayToContinue or false
  61.         if addonLoaded == addonName then
  62.        
  63.             -- If you forget to add the Achievement Addon in the required dependancies part
  64.             -- of the TOC do this to ensure the addon is loaded before you do any work
  65.             local isAchievementsLoaded = C_AddOns.IsAddOnLoaded("Blizzard_AchievementUI")
  66.             if isAchievementsLoaded then
  67.                 okayToContinue = true
  68.             else
  69.                 okayToContinue = false
  70.                 LoadAddOn("Blizzard_AchievementUI")
  71.             end
  72.         elseif addonLoaded == "Blizzard_AchievementUI" then
  73.            
  74.             -- Make sure our addon is loaded ( hopefully by now it is )
  75.             local isMyAddonLoaded = C_AddOns.IsAddOnLoaded(addonName)
  76.            
  77.             if isMyAddonLoaded then
  78.                 okayToContinue = true
  79.             end
  80.        
  81.         end
  82.        
  83.         -- The two above checks should make sure that both addons are available before
  84.         -- setting the okayToContinue variable to true.
  85.         if okayToContinue then
  86.             InitialiseMonitorTable()
  87.         end
  88.        
  89.     end    
  90.    
  91. end
  92. eventWatcher:SetScript( "OnEvent", OnEvent );
  93. eventWatcher:RegisterEvent( "ADDON_LOADED" );
  94. -- Add whatever other events you might be needing to be watched for the rest of the addons workload
  95. -- And the appropriate section in the OnEvent function


I added the assetID into the mix as you may find this useful
At the bottom of the wiki.gg page for the criteriainfo function it shows a table highlight what the assetID will be based on the type.

https://warcraft.wiki.gg/wiki/API_Ge...ntCriteriaInfo

For example:

A criteriaType of 0 will mean that this is a monster kill and the assetID will be the monsterID. The monsterID may be it's current GUID ( the GUID gets reset periodically for some things so it may be different week to week or month to month ).

A criteriaType of 43 denotes an exploration criteria and the assetID might be an ID that represents the location. Maybe a mapID, zoneID or subZone etc They don't seem to be 100% sure of this so you might find it out through testing.

Hopefully that will help you with that first part of your addon.
__________________


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-17-24, 10:51 PM   #17
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 113
It looks like we just misunderstand each other. You know English better than me, I'm from the Czech Republic and use Google Translate. =(

As I understand it, a table should appear in which data would be displayed when the achievement criterion was met? But the table does not appear. Or should she not appear? I sent the character to the desired location and the character filled out the achievement criteria. But nothing happened. I also filled out the file “myaddon.TOK” as you said in the example above.

I still don’t understand how I can look at the achievement ID criteria.

I tried to find this out using the "/etrace" command but it does not display this data.
  Reply With Quote
04-18-24, 04:11 AM   #18
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
My understanding was that ..

1. You want to know the criteria ID for an achievement's criterias. - That is what that code does
2. You wanted to be able to use that criteria information to change stuff on the map - I supplied the criteria information, you said you knew what you had to do with it so I didn't look into how to use it

This line of code is the criteria information for a single criteria for a single achievement

Lua Code:
  1. criteriaString, criteriaType, completed, quantity, reqQuantity, charName, flags, assetID, quantityString, criteriaID, eligible
  2.            = GetAchievementCriteriaInfo(achievementID, criteriaIndex)
  3.  
  4. If you add a print statement to view these values they should show in your chat window allowing you to see the criteriaID and other information you may be able to use to do what you want.   Unfortunately programming isn't something that just works, you have to investigate to see that it is doing what you want at each stage and expand on it.

This block of code is extracting key information and putting it into the data table / array for later use
Lua Code:
  1. data.criteriaID = criteriaID
  2.             data.criteriaString = criteriaString
  3.             data.criteriaType = criteriaType
  4.             data.completed = completed
  5.             data.assetID = assetID

Essentially that almost complete addon code I posted yesterday is only missing the functionality you said you knew what to do. I gave you the code to get any criteria for any achievement you want in a table/array you can access like you have done in your previous addons. You just need to add the code that uses that criteria information.
I know how I can add this to my addon so that it works, but I don’t know where to get the criteria (I only found criteria for rare monsters)
There isn't anything else I can add that will get the criteria information any differently. You just have to access the data table / array my code creates in the code you already know what to do.
__________________


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, 04:34 AM   #19
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,935
What might be missing to help you is how to access the table of information for a particular criteria.


So let's see.

Let's use the achievement 6351 ( Explore Jade Forest ).

We would have something like.

uhoh .. missed a vital bit of code out .. my code will only ever store one criteria.


Let me do some coding with testing and get back to you with some examples on how it can be used - like for exploration etc.
__________________


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:05 AM   #20
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 113
I found a solution to my problem. And I publish it here:
Addon "idTip" and Addon "idTip Community Fork".

Thank you all very much for your help in my project.
  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