I noticed that the WAR API that most point to (located here: https://web.archive.org/web/20090307230 ... ki/WAR_API) does not document what the callback of an event listener receives as arguments. I wanted to share my experience figuring out what was returned when I was listening to the event AUCTION_SEARCH_RESULT_RECEIVED.
Getting started
When you launch RoR and play as a character, you can type /d in the chat box to pull up a debug menu. Click the turn on logs button. Make sure your log isin't filtering out debug statements. (tip: hiding the SoR addon by clicking on the minimap button will stop a good portion of the spam).
Debug logs are kept in <RoR Installation Directory>/logs, so anything we print using d() in an addon or using /script will appear in both the /d window in-game and the .txt file in the logs directory.
RoR's events and listening to them
RoR seems to re-implement the SystemData variable, which all addons should have access to. You can find the old WAR implementation (which seems respected by RoR) here: https://web.archive.org/web/20090302085 ... SystemData
In your addon, register an event handler:
Code: Select all
RegisterEventHandler(SystemData.Events.AUCTION_SEARCH_RESULT_RECEIVED, "Foobar")
Inspect the arguments to our callback
In lua, you can specify that a function will receive an unspecified amount of arguments placing "..." in lieu of the arguments list. This will provide us with an "args" variable that contains the arguments given to the function.
Code: Select all
RegisterEventHandler(SystemData.Events.AUCTION_SEARCH_RESULT_RECEIVED, "Foobar")
function Foobar(...)
-- "arg" variable is a table containing the arguments.
end
Now, we need to format the args variables in a human readable way. RoR has a built in DUMP_TABLE function that works excellently:
Code: Select all
RegisterEventHandler(SystemData.Events.AUCTION_SEARCH_RESULT_RECEIVED, "Foobar")
function Foobar(...)
DUMP_TABLE(arg)
end
If you look open the /d menu in RoR or open the .txt file in your /logs folder, you should see the arguments that were passed to Foobar and their contents. In the case of AUCTION_SEARCH_RESULT_RECEIVED, I see a list of auctions, where each auction looks like this:
Code: Select all
[revision] 1
[itemData]
[description]
[iLevel] 51
...
[auctionIDHigherNum] 0
[sellerName] Johndon
[buyOutPrice] 90000
[timeLeft] 3
[auctionIDLowerNum] 4936576
Code: Select all
RegisterEventHandler(SystemData.Events.AUCTION_SEARCH_RESULT_RECEIVED, "Foobar")
function Foobar(auctions)
for _, auction in ipairs(results) do
d(auction.buyOutPrice)
end
end