SaddlebagExchangeWoW

SaddlebagExchangeWoW

740 Downloads

Move notes over

cohenaj194 opened this issue ยท 0 comments

commented

Will dump my notes in here for making a wow addon

more info


ok got a working command, the trick is that all the auction house stuff needs to start with C_AuctionHouse https://wowwiki-archive.fandom.com/wiki/World_of_Warcraft_API#Auction

/run C_AuctionHouse.CloseAuctionHouse();

here it is in a slash command in the addon

message('My first addon!')

SLASH_HELLOWORLD1, SLASH_HELLOWORLD2 = '/hiw', '/hellow';
local function handler(msg, editBox)
    if msg == 'bye' then
        print('Goodbye, World!')
    else
        -- print("Hello, World!");
        -- C_AuctionHouse.CloseAuctionHouse();

        -- this below only works if you are at the auction house looking at your auctions
        ownedAuctions=C_AuctionHouse.GetOwnedAuctions();
        print("Found", table.maxn(ownedAuctions), "active auctions.")
        -- need to figure out how to print this table
    end
end
SlashCmdList["HELLOWORLD"] = handler; -- Also a valid assignment strategy

notes:


Ok got it working to the point where i can make the addon

main.lua

-- message('My first addon!')

local function get_keys(t)
  local keys={}
  for key,_ in pairs(t) do
    table.insert(keys, key)
  end
  return keys
end

SLASH_HELLOWORLD1, SLASH_HELLOWORLD2 = '/hiw', '/hellow';
local function handler(msg, editBox)
    if msg == 'bye' then
        print('Goodbye, World!')
    else
        -- print("test")
        ownedAuctions=C_AuctionHouse.GetOwnedAuctions();
        print("Found", table.maxn(ownedAuctions), "active auctions.")

        -- gets the auction id
        -- print(ownedAuctions[1]["auctionID"])

        -- doesnt work but it does show me the 
        -- print(table.concat(ownedAuctions))

        -- loop through auctions
        for k, v in pairs(ownedAuctions) do

            print('======')
            print("auction keys")
            for i, j in pairs(v) do
                print(i)
            end

            print('-----')
            print("itemKey info")
            for i, j in pairs(v["itemKey"]) do
                print(i)
            end
            print()
            print("itemID found!", v["itemKey"]["itemID"])
            print("price found!", v["buyoutAmount"])
        end

    end
end
SlashCmdList["HELLOWORLD"] = handler; -- Also a valid assignment strategy

output example, this has extra text so i can figure out wtf is in those tables, the point is now we can get the price and item id when a user looks at their auctions

image

Found 3 active auctions.
======
auction keys
itemKey
timeLeftSeconds
buyoutAmount
quantity
status
auctionID
-----
itemKey info
itemLevel
itemSuffix
itemID
battlePetSpeciesID

itemID found! 194124
price found! 582100
======
auction keys
itemKey
timeLeftSeconds
buyoutAmount
quantity
status
auctionID
-----
itemKey info
itemLevel
itemSuffix
itemID
battlePetSpeciesID

itemID found! 194123
price found! 50100
======
auction keys
itemKey
timeLeftSeconds
buyoutAmount
quantity
status
auctionID
-----
itemKey info
itemLevel
itemSuffix
itemID
battlePetSpeciesID

itemID found! 194124
price found! 600200

jackpot