WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Tracking currency updates (https://www.wowinterface.com/forums/showthread.php?t=56052)

Layback_ 02-17-18 02:31 AM

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?

Phanx 02-17-18 04:22 AM

Quote:

Originally Posted by Layback_ (Post 326952)
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).

Layback_ 02-17-18 06:47 AM

Quote:

Originally Posted by Phanx (Post 326954)
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?

Quote:

Originally Posted by Phanx (Post 326954)
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? :D

Phanx 02-19-18 09:49 AM

Quote:

Originally Posted by Layback_ (Post 326955)
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)

arith 04-25-18 09:14 PM

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.


All times are GMT -6. The time now is 04:30 AM.

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