WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   QueryAuctionItems not working (https://www.wowinterface.com/forums/showthread.php?t=58562)

S4m 01-23-21 09:11 AM

QueryAuctionItems not working
 
Hello, I'm new to addon development and can't get QueryAuctionItems to work. (it's for WoW Classic).

AUCTION_ITEM_LIST_UPDATE fires when searching manually, but not when programmatically queried. However, "AH is queryable" is printed. On a super rare occasion it has worked, and I have no idea why. The code is below, surely I'm doing something wrong.

Code:

Sandbox = { }

-- Code ...
local frame = CreateFrame("FRAME");
frame:RegisterEvent("ADDON_LOADED");
frame:RegisterEvent("PLAYER_LOGOUT");
frame:RegisterEvent("AUCTION_ITEM_LIST_UPDATE");
frame:RegisterEvent("AUCTION_HOUSE_SHOW");

-- Slash Commands ...
SlashCmdList["SANDBOX"] = function()
    print("Slash Sandbox");
    frame:QueryAH();     
end
SLASH_SANDBOX1 = "/sandbox";
SLASH_SANDBOX2 = "/sb";

function frame:OnEvent(event, arg1)
    if event == "ADDON_LOADED" and arg1 == "Sandbox" then
        print("Sandbox");
    end

    if event == "AUCTION_ITEM_LIST_UPDATE" then
        print("AH update");
        batch,count = GetNumAuctionItems("list");
    end

    if event == "AUCTION_HOUSE_SHOW" then
        print("AH show");
        frame:QueryAH();
    end
end

frame:SetScript("OnEvent", frame.OnEvent);

function frame:QueryAH()
    if CanSendAuctionQuery() then
        print("AH is queryable");
        QueryAuctionItems("", nil, nil, 0, 0, 0, 0, 0, 0, 0);       
    else
        print("AH is not queryable");
    end
end

Much appreciated.

S4m 01-24-21 06:18 PM

EDIT problem found
 
I think I found it, upon looking again. I noticed it only works once, so e.g. upon every login - a detail I somehow missed and failed to check. Two things obscured it. The query has a small loading time. Furthermore, the search results displayed are wiped after changing tabs (bids, or own auctions). So, switching tabs before the results were displayed made it seem like nothing had happened, although the messages were printed. And subsequent queries via the slash command didn't actually alter the already existing results, so 'update' didn't fire.

The following are some directions regarding my question from another forum. They're a bit fragmented, but might be helpful nonetheless:

Quote:

is the AH window open when the query is fired?

does lua require return types

in function headers

I've never used it

I just don't know if this function returns a value or not

QueryAuctionItems

looks like it doesn't?

in someone else's code they do this:

Code:

QueryAuctionItems(name, nil, nil, 0, 0, 0, Scan.tryPage, 0, 0)
Scan.eventObject:RegisterEvent("AUCTION_ITEM_LIST_UPDATE", function()
Scan.eventObject:UnregisterEvent("AUCTION_ITEM_LIST_UPDATE")
Scan.eventObject.frame:Show()

is the auction item list update thing sep

is it a flag

that you mark as set

and the frame checks that when it redraws?

i've never worked with this stuff but that's what i'd guess

you'd need to manually register and unregister the event

and refresh the frame

the show() call is probably doing it there

it's like with file io where you are manipulating a buffer the whole time until you sync() or flush() the buffer


All times are GMT -6. The time now is 10:34 AM.

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