Quantcast Tracking currency updates - WoWInterface
Thread Tools Display Modes
02-17-18, 02:31 AM   #1
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 356
Tracking currency updates

So, I am trying to track couple of currencies (money, order resources, etc.) when there is an update (either gain or loss).

I guess money could be easily tracked via PLAYER_MONEY event, but still ain't sure of other currencies.

According to the description on Wowpedia, CURRENCY_DISPLAY_UPDATE event fires 'every time the UI need to draw the currencies list' and I'm not quite sure of which UI it is referring to.

CHAT_MSG_CURRENCY seems to handle gain, but not too sure about loss.
(Never seen a message on loss)

What could be the best possible solution, here?

Last edited by Layback_ : 02-17-18 at 04:02 AM.
  Reply With Quote
02-17-18, 04:22 AM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Layback_ View Post
According to the description on Wowpedia, CURRENCY_DISPLAY_UPDATE event fires 'every time the UI need to draw the currencies list' and I'm not quite sure of which UI it is referring to.
It's the list of currencies you see when you click the "Currency" tab on the bottom of the character (equipped items) frame.

That said, in my own currency addon I just hook (non-intrusively with hooksecurefunc) "TokenFrame_Update" and "BackpackTokenFrame_Update" to detect currency updates, though I don't remember why I did that instead of listening for some event(s).
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote
02-17-18, 06:47 AM   #3
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 356
Originally Posted by Phanx View Post
That said, in my own currency addon I just hook (non-intrusively with hooksecurefunc) "TokenFrame_Update" and "BackpackTokenFrame_Update" to detect currency updates,
So, do "TokenFrame_Update" function and "CURRENCY_DISPLAY_UPDATE" event get called simultaneously?

Originally Posted by Phanx View Post
though I don't remember why I did that instead of listening for some event(s).
Could you please tell me what those event(s) could be?

Last edited by Layback_ : 02-17-18 at 06:53 AM.
  Reply With Quote
02-19-18, 09:49 AM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Layback_ View Post
So, do "TokenFrame_Update" function and "CURRENCY_DISPLAY_UPDATE" event get called simultaneously?
That question doesn't make any sense. Events don't get called. Events fire (that is to say, they are emitted by the game, and that action occurs in the underlying C code, not in the Lua code that creates and controls the UI) and UI code can listen for events and call functions in response to them.

If you're asking whether the UI calls TokenFrame_Update in response to CURRENCY_DISPLAY_UPDATE, the answer now appears to be yes, which means I could probably use an event handler instead of hooking functions in my addon if I wanted to bother changing it. Like I said, I don't recall why I used that solution when I wrote my addon 8 years ago.

That also means that the answer to your original question is probably that the best solution here is to listen for the CURRENCY_DISPLAY_UPDATE event. If you try that, and are seeing currency numbers changing without the event firing, report back with a description of the circumstances.

Lua Code:
  1. local f = CreateFrame("Frame")
  2. f:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
  3. f:SetScript("OnEvent", function(f, e, ...)
  4.    print(e, ...)
  5. end)
__________________
Author/maintainer of Grid, PhanxChat, oUF_Phanx, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
  Reply With Quote
04-25-18, 09:14 PM   #5
arith
A Cyclonian
 
arith's Avatar
AddOn Author - Click to view addons
Join Date: May 2009
Posts: 41
FYI, I tracked on below events:
Code:
	"BAG_UPDATE",
	"TRADE_CURRENCY_CHANGED",
	"ARTIFACT_UPDATE",
	"ARTIFACT_XP_UPDATE",
	"TRADE_PLAYER_ITEM_CHANGED",
	"PLAYER_TRADE_CURRENCY",
	"CHAT_MSG_CURRENCY",
	"SHIPMENT_CRAFTER_REAGENT_UPDATE",
	"CURRENCY_DISPLAY_UPDATE",
	-- Money
	"PLAYER_MONEY",
	"PLAYER_TRADE_MONEY",
	"TRADE_MONEY_CHANGED",
	"SEND_MAIL_MONEY_CHANGED",
	"SEND_MAIL_COD_CHANGED",
	"TRIAL_STATUS_UPDATE",
	"CHAT_MSG_MONEY",
You probably don't need all of them.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Tracking currency updates

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off