-
Posted by Philburt on Wed, 18 Nov 2009 11:59:57
Placing a bid at the Auction House using:
PlaceAuctionBid("list",index,amount)
results in a message in the chatframe telling me that either: 1) the bid was successful, or 2) the auction no longer exists (bought by another player, or the time ran out)If the amount is equal to the buyout price of the item, I'm given a message that the buyout was successful and the item appears in my mailbox.
What I need to know is how do I check for these possible outcomes in LUA? I had hoped that the PlaceAuctionBid function would return a value depending on the outcome, but no such luck. Any ideas?
-
Posted by jnwhiteh on Wed, 18 Nov 2009 12:41:43
Placing a bid at the Auction House using:
PlaceAuctionBid("list",index,amount)
results in a message in the chatframe telling me that either: 1) the bid was successful, or 2) the auction no longer exists (bought by another player, or the time ran out) If the amount is equal to the buyout price of the item, I'm given a message that the buyout was successful and the item appears in my mailbox.What I need to know is how do I check for these possible outcomes in LUA? I had hoped that the PlaceAuctionBid function would return a value depending on the outcome, but no such luck. Any ideas?
Inevitably there is an event that fires when the auction bid is successful, since the PlaceAuctionBid function has to communicate with the server and that's the only way we get notified of the other side of server events. That's almost certainly what is being used to generate the chat message.
-
Posted by Philburt on Wed, 18 Nov 2009 13:59:27
Yes, I thought there may be an Event somewhere, but no list I've checked mentions one. I've noticed that Auctioneer hooks into the message functions and checks for the actual message appearing in the chatframe. This may be the only way of doing it, but another possibility that I'll try first (a little nervous of function-hooking to tell the truth), is waiting for a few seconds, and see if the GetMoney() value changes. That would indicate a sucessfull buyout, although I would have no indication as to why a buyout failed. Still, thanks for your input.
-
Posted by jnwhiteh on Wed, 18 Nov 2009 20:28:43
If that's what Auctioneer uses, you should use it to. It's almost certainly the best way to do it.
-
Posted by jnwhiteh on Wed, 18 Nov 2009 22:22:24
Also.. you shouldn't "look" for events on lists. If you can reproduce the conditions in-game. Use the built-in event tracer and look at what events fire. /eventtrace I believe starts it.
-
Posted by Philburt on Thu, 19 Nov 2009 14:48:43
Thanks for your input on this one, and your pointers helped me find an answer, which I'll give here to help anyone else.
I was already using Events to listen for
AUCTION_ITEM_LIST_UPDATE
, so it was just a matter of adjusting the code to also listen forCHAT_MSG_SYSTEM
as well. The basic code is as follows:function ptlFrame1_OnLoad() DoTheRegistering() end function MyFrame1_OnEvent(frame,event,arg1,...) if event=="CHAT_MSG_SYSTEM" then if arg1==ERR_AUCTION_BID_PLACED then -- code for showing a bid has been placed end if string.sub(arg1,1,18)=="You won an auction" then -- code for showing an auction has been won end end end function DoTheRegistering() MyFrame1:RegisterEvent("CHAT_MSG_SYSTEM") end
Notes: I use the string.sub function because that is enough of the text to check that my auction buyout was sucessfull. The full string would normally be : "You won an auction for %s" where %s is the name of the item. I dont need the name, just the fact that the auction was won.
ERR_AUCTION_BID_PLACED
is the global string for giving the message "Bid Accepted." "You have won an auction for %s" is also in the global string list asERR_AUCTION_WON_S
, but I wasn't to sure how to handle the %s part of the string, so I made use of the string.sub function as above.There are probably better ways of doing this. I tried hooking the function in a similar way to Auctioneer, but I got terribly confused and reverted to this. I'll get the hang of hooking eventually, (which will probably mean a re-write of my code), but until then I'll just plod along with what works, even if it does mean checking that it still works after patches.