I'm trying to create my first addon to cycle through all trading house pages of all my guilds. My script does this loop adequately enough for a first attempt, except it does it too quickly. It gets to the point that it tries to execute a search while waiting for the previous search to complete and I get the "Another action is in process" or similar error in the top right corner of my screen after the first result is processed.
What I want to know is, is there a way to infinite loop (or pause) until there are no pending trading house actions? I found this global variable on the wiki.esoui.com page, but, being a n00b, I don't understand how I can check/use it to my advantage. I've tried looking at examples of other scripts that use those globals, but their implementations cause mine to freeze. I tried a while do loop where the --COMMENT-- is in my code below, to check if the global was set; but it just caused my game to crash.
GLOBAL - TRADING_HOUSE_RESULT_SEARCH_PENDING
Any suggestions or guidance?
Code:
function THP.getStoreListings(guildId)
local numPages
if SelectTradingHouseGuildId(guildId) then
ClearAllTradingHouseSearchTerms()
for var=1,100 do
--If Another Trading House Action Is In Progress Wait for it to complete--
ExecuteTradingHouseSearch(var, TRADING_HOUSE_SORT_SALE_PRICE, true)
for index=1,100 do
local icon, itemName, quality, stackCount, sellerName, timeRemaining, purchasePrice = GetTradingHouseSearchResultItemInfo(index)
if icon then
THP.print(stackCount .. "x " .. itemName)
end
end
end
end
end
Thank you,
Durstie