WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Simple auc question - How to browse all batte pets? (https://www.wowinterface.com/forums/showthread.php?t=58016)

Robotron 05-22-20 01:00 PM

Simple auc question - How to browse all batte pets?
 
Lua Code:
  1. local query = {
  2.    searchString = "",
  3.    sorts = { sortOrder=0, reverseSort=false },
  4.    itemClassFilters = { classID = LE_ITEM_CLASS_BATTLEPET }
  5. }
  6.  
  7. C_AuctionHouse.SendBrowseQuery(query)
This code doesn't work.

Xrystal 05-23-20 04:59 AM

This was what I ended up getting to roughly work - still not exactly the results I wanted but if you are not getting anything then this may help you get started. Feel free to use the code .. I don't intend to make an auction house addon at present, this was just a simple test run on how to use the new features for a query posted a short while back ( https://www.wowinterface.com/forums/...ad.php?t=57985 )

Lua Code:
  1. XrystalUI_Auctioneer_Info = XrystalUI_Auctioneer_Info or {}
  2.  
  3. local querySent = false
  4.  
  5. local function OnEvent(self, event, ...)
  6.    
  7.     if event == "AUCTION_HOUSE_SHOW" then  
  8.  
  9.         local searchString = "Netherweave"
  10.         local minLevel = nil
  11.         local maxLevel = nil
  12.         local filtersArray = nil
  13.         local filterData = { classID = LE_ITEM_CLASS_CONTAINER, subClassID = nil, inventoryType = nil }
  14.         local sorts = { sortOrder = Enum.AuctionHouseSortOrder.Price, reverseSort = false }
  15.        
  16.         local query = {};
  17.         query.searchString = searchString;
  18.         query.minLevel = minLevel;
  19.         query.maxLevel = maxLevel;
  20.         query.filters = filtersArray;
  21.         query.itemClassFilters = filterData;
  22.         query.sorts = sorts
  23.        
  24.         XrystalUI_Auctioneer_Info = {}
  25.         print("Sending Browse Query Automatically")
  26.         C_AuctionHouse.SendBrowseQuery(query);        
  27.        
  28.     elseif event == "AUCTION_HOUSE_BROWSE_RESULTS_UPDATED" then
  29.        
  30.         -- Get the first 500 items
  31.         local results = C_AuctionHouse.GetBrowseResults()
  32.        
  33.          local itemKey = results[1].itemKey
  34.          local sorts = { sortOrder = Enum.AuctionHouseSortOrder.Price, reverseSort = false }
  35.          local separateOwnerItems = true
  36.          print("Automatically searching for item ", itemKey)
  37.          C_AuctionHouse.SendSearchQuery(itemKey, sorts, separateOwnerItems)
  38.        
  39.        
  40.         -- Store for later retrieval
  41.         XrystalUI_Auctioneer_Info["BrowseResults"] = results
  42.        
  43.     elseif event == "AUCTION_HOUSE_NEW_RESULTS_RECEIVED" then
  44.         local itemKey = ...
  45.         if ( itemKey ) then
  46.            
  47.             -- Retrieve Info about this item
  48.             local itemKeyInfo = C_AuctionHouse.GetItemKeyInfo(itemKey)
  49.            
  50.             -- Store for later retrieval
  51.             XrystalUI_Auctioneer_Info["NewResults"] = XrystalUI_Auctioneer_Info["NewResults"] or {}
  52.             XrystalUI_Auctioneer_Info["NewResults"]["itemKey"] = {}
  53.             XrystalUI_Auctioneer_Info["NewResults"]["itemKey"].Key = itemKey
  54.             XrystalUI_Auctioneer_Info["NewResults"]["itemKey"].Info = itemKeyInfo
  55.            
  56.             -- Request more details about this item's auctions
  57.             local sorts = { sortOrder = Enum.AuctionHouseSortOrder.Price, reverseSort = false }
  58.             local separateOwnerItems = true
  59.             C_AuctionHouse.SendSearchQuery(itemKey, sorts, separateOwnerItems)
  60.            
  61.         end
  62.        
  63.     elseif event == "ITEM_SEARCH_RESULTS_UPDATED" then
  64.         local itemKey, auctionID = ...
  65.         local itemID = itemKey.itemID
  66.         if itemKey then
  67.            
  68.             -- Get the number of auctions for this itemKey
  69.             local numResults = C_AuctionHouse.GetNumItemSearchResults(itemKey)
  70.  
  71.             -- Store for later retrieval
  72.             XrystalUI_Auctioneer_Info["ItemSearchResults"] = XrystalUI_Auctioneer_Info["ItemSearchResults"] or {}
  73.             XrystalUI_Auctioneer_Info["ItemSearchResults"][itemID] = {}
  74.             XrystalUI_Auctioneer_Info["ItemSearchResults"][itemID].itemKey = itemKey
  75.             XrystalUI_Auctioneer_Info["ItemSearchResults"][itemID].auctionID = auctionID
  76.             XrystalUI_Auctioneer_Info["ItemSearchResults"][itemID].Auctions = {}
  77.  
  78.             -- Get the auction entries for this item
  79.             for index = 1, numResults do        
  80.                 local result = C_AuctionHouse.GetItemSearchResultInfo(itemKey, index)
  81.                
  82.                 -- Add this entry to our list of auctions
  83.                 table.insert(XrystalUI_Auctioneer_Info["ItemSearchResults"][itemID].Auctions,result)
  84.             end
  85.  
  86.            
  87.         end
  88.                
  89.     elseif event == "COMMODITY_SEARCH_RESULTS_UPDATED" then
  90.         local itemID = ...
  91.         if itemID then
  92.            
  93.             -- Get the number of auctions for this commodity item
  94.             local numResults = C_AuctionHouse.GetNumCommoditySearchResults(itemID)
  95.            
  96.             -- Store for later retrieval
  97.             XrystalUI_Auctioneer_Info["CommoditiesSearchResults"] = XrystalUI_Auctioneer_Info["CommoditiesSearchResults"] or {}
  98.             XrystalUI_Auctioneer_Info["CommoditiesSearchResults"][itemID] = {}
  99.             XrystalUI_Auctioneer_Info["CommoditiesSearchResults"][itemID].Auctions = {}
  100.            
  101.             -- Get the auction entries for this commodity
  102.             for index = 1,numResults do
  103.                 local result = C_AuctionHouse.GetCommoditySearchResultInfo(itemID, index)
  104.                 table.insert(XrystalUI_Auctioneer_Info["CommoditiesSearchResults"][itemID].Auctions,result)
  105.             end
  106.         end
  107.     end
  108. end
  109.  
  110. local f = CreateFrame("Frame")
  111. f:RegisterEvent("AUCTION_HOUSE_SHOW")
  112. f:RegisterEvent("AUCTION_HOUSE_BROWSE_RESULTS_UPDATED")
  113. f:RegisterEvent("AUCTION_HOUSE_NEW_RESULTS_RECEIVED") -- [itemKey]
  114. f:RegisterEvent("ITEM_SEARCH_RESULTS_UPDATED")
  115. f:RegisterEvent("COMMODITY_SEARCH_RESULTS_UPDATED")
  116. f:SetScript("OnEvent", OnEvent)

Robotron 05-28-20 12:06 PM

I took this piece of code from your example, and it doesn't work.
Each time i run it it return different results and filter by class doesn't applied.

Lua Code:
  1. local searchString = "Netherweave"
  2.         local minLevel = nil
  3.         local maxLevel = nil
  4.         local filtersArray = nil
  5.         local filterData = { classID = LE_ITEM_CLASS_CONTAINER, subClassID = nil, inventoryType = nil }
  6.         local sorts = { sortOrder = Enum.AuctionHouseSortOrder.Price, reverseSort = false }
  7.        
  8.         local query = {};
  9.         query.searchString = searchString;
  10.         query.minLevel = minLevel;
  11.         query.maxLevel = maxLevel;
  12.         query.filters = filtersArray;
  13.         query.itemClassFilters = filterData;
  14.         query.sorts = sorts
  15.        
  16.         C_AuctionHouse.SendBrowseQuery(query);

Xrystal 05-28-20 02:18 PM

Yeah, I had similar issues, which is why I said it will get you started ..

I was searching for bag ( item class ) netherweave ( search pattern ) and got a bunch of netherweave stuff .. and maybe bags .. it was a while ago and I can't remember everything that was returned. So, maybe the search pattern is an 'or' situation rather than an 'and' situation.

I searched for bags or something with netherweave in the description .. and that is what I may well have got.


So, based on the search patterns, are the results possibly being returned correctly, just not what we were expecting ?

Robotron 08-10-20 01:49 PM

Credits: plusmouse from https://discord.gg/cXFrth
Code:

local query = {
  searchString = "",
  sorts = { { sortOrder=0, reverseSort=false } },
  itemClassFilters = { { classID = LE_ITEM_CLASS_BATTLEPET } },
  filters = {}
}

C_AuctionHouse.SendBrowseQuery(query)

sorts is a list of the sorting values. Notice the type signature in the docs AuctionHouseSortType[] and the same for itemClassFilters being AuctionHouseItemClassFilter[]
https://www.townlong-yak.com/framexm...endBrowseQuery


All times are GMT -6. The time now is 02:58 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI