XrystalUI_Auctioneer_Info = XrystalUI_Auctioneer_Info or {}
local querySent = false
local function OnEvent(self, event, ...)
if event == "AUCTION_HOUSE_SHOW" then
local searchString = "Netherweave"
local minLevel = nil
local maxLevel = nil
local filtersArray = nil
local filterData = { classID = LE_ITEM_CLASS_CONTAINER, subClassID = nil, inventoryType = nil }
local sorts = { sortOrder = Enum.AuctionHouseSortOrder.Price, reverseSort = false }
local query = {};
query.searchString = searchString;
query.minLevel = minLevel;
query.maxLevel = maxLevel;
query.filters = filtersArray;
query.itemClassFilters = filterData;
query.sorts = sorts
XrystalUI_Auctioneer_Info = {}
print("Sending Browse Query Automatically")
C_AuctionHouse.SendBrowseQuery(query);
elseif event == "AUCTION_HOUSE_BROWSE_RESULTS_UPDATED" then
-- Get the first 500 items
local results = C_AuctionHouse.GetBrowseResults()
local itemKey = results[1].itemKey
local sorts = { sortOrder = Enum.AuctionHouseSortOrder.Price, reverseSort = false }
local separateOwnerItems = true
print("Automatically searching for item ", itemKey)
C_AuctionHouse.SendSearchQuery(itemKey, sorts, separateOwnerItems)
-- Store for later retrieval
XrystalUI_Auctioneer_Info["BrowseResults"] = results
elseif event == "AUCTION_HOUSE_NEW_RESULTS_RECEIVED" then
local itemKey = ...
if ( itemKey ) then
-- Retrieve Info about this item
local itemKeyInfo = C_AuctionHouse.GetItemKeyInfo(itemKey)
-- Store for later retrieval
XrystalUI_Auctioneer_Info["NewResults"] = XrystalUI_Auctioneer_Info["NewResults"] or {}
XrystalUI_Auctioneer_Info["NewResults"]["itemKey"] = {}
XrystalUI_Auctioneer_Info["NewResults"]["itemKey"].Key = itemKey
XrystalUI_Auctioneer_Info["NewResults"]["itemKey"].Info = itemKeyInfo
-- Request more details about this item's auctions
local sorts = { sortOrder = Enum.AuctionHouseSortOrder.Price, reverseSort = false }
local separateOwnerItems = true
C_AuctionHouse.SendSearchQuery(itemKey, sorts, separateOwnerItems)
end
elseif event == "ITEM_SEARCH_RESULTS_UPDATED" then
local itemKey, auctionID = ...
local itemID = itemKey.itemID
if itemKey then
-- Get the number of auctions for this itemKey
local numResults = C_AuctionHouse.GetNumItemSearchResults(itemKey)
-- Store for later retrieval
XrystalUI_Auctioneer_Info["ItemSearchResults"] = XrystalUI_Auctioneer_Info["ItemSearchResults"] or {}
XrystalUI_Auctioneer_Info["ItemSearchResults"][itemID] = {}
XrystalUI_Auctioneer_Info["ItemSearchResults"][itemID].itemKey = itemKey
XrystalUI_Auctioneer_Info["ItemSearchResults"][itemID].auctionID = auctionID
XrystalUI_Auctioneer_Info["ItemSearchResults"][itemID].Auctions = {}
-- Get the auction entries for this item
for index = 1, numResults do
local result = C_AuctionHouse.GetItemSearchResultInfo(itemKey, index)
-- Add this entry to our list of auctions
table.insert(XrystalUI_Auctioneer_Info["ItemSearchResults"][itemID].Auctions,result)
end
end
elseif event == "COMMODITY_SEARCH_RESULTS_UPDATED" then
local itemID = ...
if itemID then
-- Get the number of auctions for this commodity item
local numResults = C_AuctionHouse.GetNumCommoditySearchResults(itemID)
-- Store for later retrieval
XrystalUI_Auctioneer_Info["CommoditiesSearchResults"] = XrystalUI_Auctioneer_Info["CommoditiesSearchResults"] or {}
XrystalUI_Auctioneer_Info["CommoditiesSearchResults"][itemID] = {}
XrystalUI_Auctioneer_Info["CommoditiesSearchResults"][itemID].Auctions = {}
-- Get the auction entries for this commodity
for index = 1,numResults do
local result = C_AuctionHouse.GetCommoditySearchResultInfo(itemID, index)
table.insert(XrystalUI_Auctioneer_Info["CommoditiesSearchResults"][itemID].Auctions,result)
end
end
end
end
local f = CreateFrame("Frame")
f:RegisterEvent("AUCTION_HOUSE_SHOW")
f:RegisterEvent("AUCTION_HOUSE_BROWSE_RESULTS_UPDATED")
f:RegisterEvent("AUCTION_HOUSE_NEW_RESULTS_RECEIVED") -- [itemKey]
f:RegisterEvent("ITEM_SEARCH_RESULTS_UPDATED")
f:RegisterEvent("COMMODITY_SEARCH_RESULTS_UPDATED")
f:SetScript("OnEvent", OnEvent)