View Single Post
05-23-20, 04:59 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
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)
__________________
  Reply With Quote