Thread Tools Display Modes
11-29-16, 03:12 AM   #1
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Documenting events

I came across a thread where the related events for an issue were discovered by reading through Blizzard's UI code, but the arguments or parameters were unknown for those events.

There must be a way to learn what those are, preferably without registering for the events, and playing the game hoping they fire.

I got as far as this:
Lua Code:
  1. -- register event and process
  2.  
  3. -- handle it
  4. function MyAddOn:SomeRegisteredEvent(event, ...)
  5.     for key, arg in pairs(...) do
  6.         print(key .. " " .. arg)
  7.     end
  8. end
  Reply With Quote
11-29-16, 08:43 AM   #2
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
I'm using a simple little tracer addon to look into specific events:
Lua Code:
  1. local EV = CreateFrame('Frame')
  2. local HEADER, COAT = '|cffff7d0aTracer|r ', '|cffffe00a%s|r'
  3.  
  4. local function trace(msg)
  5.     msg = strupper(msg)
  6.     if msg == 'ALL' then
  7.         EV:RegisterAllEvents()
  8.     else
  9.         EV:RegisterEvent(msg)
  10.     end
  11.     print(HEADER, COAT:format('Tracing event'), msg)
  12. end
  13.  
  14.  
  15. local function untrace(msg)
  16.     msg = strupper(msg)
  17.     if msg == 'ALL' then
  18.         EV:UnregisterAllEvents()
  19.     else
  20.         EV:UnregisterEvent(msg)
  21.     end
  22.     print(HEADER, COAT:format('Stopped tracing'), msg)
  23. end
  24.  
  25.  
  26. SLASH_TRACE1 = '/trace'
  27. SLASH_TRACE2 = '/traceevent'
  28. SlashCmdList['TRACE'] = trace
  29.  
  30.  
  31. SLASH_UNTRACE1 = '/untrace'
  32. SLASH_UNTRACE2 = '/untraceevent'
  33. SlashCmdList['UNTRACE'] = untrace
  34.  
  35. -- Event catcher
  36. function EV:OnEvent(event, ...)
  37.     print(HEADER, COAT:format(event), date('%H:%M:%S'))
  38.     for i, arg in pairs({...}) do
  39.         print('   ', COAT:format(i), arg)
  40.     end
  41. end
  42.  
  43. EV:SetScript('OnEvent', EV.OnEvent)

Usage:
Lua Code:
  1. /trace PLAYER_TARGET_CHANGED -- start trace
  2. /untrace PLAYER_TARGET_CHANGED -- stop trace
  3.  
  4. /trace all -- trace all events
  5. /untrace all -- untrace all events
__________________

Last edited by MunkDev : 11-29-16 at 08:49 AM.
  Reply With Quote
11-29-16, 08:49 AM   #3
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
The "/etrace" command is built into the game and provides a graphical interface for monitoring all events. You can easily remove events you're not interested in (eg. CLEU) by clicking the "X" next to them in the monitor. I've long thought about writing an addon to extend the Blizzard event monitor to make it easier to remove common spammy events, only listen for specific events, filter by unit, etc. but never got around to it.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
11-29-16, 08:52 AM   #4
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
I usually only use the /eventtrace tool when I'm looking for an event that I don't know of yet, but since it's so verbose and instead of filtering what you're looking for you have to filter out everything you're not looking for, I avoid using it unless I have to. If you don't get around to it Phanx, I probably will.
__________________
  Reply With Quote
11-29-16, 01:21 PM   #5
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by Phanx View Post
You can easily remove events you're not interested in (eg. CLEU) by clicking the "X" next to them in the monitor.

  Reply With Quote
11-29-16, 01:46 PM   #6
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Usually I'd just use the chatframe /w print lines for debugging events

I remember unregistering this list of events from the EventTraceFrame, but those were from 2 years ago and I just wanted to get rid of anything that fired a lot
But maybe having a white list would be more effective in some cases lol. Wasn't the original DevTools addon able to do that btw?
Code:
ACTIONBAR_HIDEGRID
ACTIONBAR_SHOWGRID
ACTIONBAR_SLOT_CHANGED
ACTIONBAR_UPDATE_COOLDOWN
ACTIONBAR_UPDATE_STATE
ACTIONBAR_UPDATE_USABLE
BAG_UPDATE_COOLDOWN
CHAT_MSG_ADDON
CHAT_MSG_COMBAT_MISC_INFO
CHAT_MSG_GUILD_ACHIEVEMENT
CHAT_MSG_SYSTEM
COMBAT_LOG_EVENT
COMBAT_LOG_EVENT_UNFILTERED
COMBAT_RATING_UPDATE
COMBAT_TEXT_UPDATE
COMPANION_UPDATE
CRITERIA_UPDATE
CURRENT_SPELL_CAST_CHANGED
CURSOR_UPDATE
FRIENDLIST_UPDATE
GOSSIP_CLOSED
GOSSIP_CONFIRM_CANCEL
GOSSIP_SHOW
GUILD_NEWS_UPDATE
GUILD_RANKS_UPDATE
GUILD_ROSTER_UPDATE
GUILD_TRADESKILL_UPDATE
GUILD_XP_UPDATE
INSPECT_READY
MASTERY_UPDATE
MINIMAP_UPDATE_ZOOM
MIRROR_TIMER_STOP
MODIFIER_STATE_CHANGED
NEW_WMO_CHUNK
PET_BAR_UPDATE_USABLE
PLAYER_DAMAGE_DONE_MODS
PLAYER_FLAGS_CHANGED
PLAYER_TALENT_UPDATE
PLAYER_TARGET_CHANGED
SKILL_LINES_CHANGED
SPELLS_CHANGED
SPELL_POWER_CHANGED
SPELL_UPDATE_COOLDOWN
SPELL_UPDATE_USABLE
UI_ERROR_MESSAGE
UNIT_ATTACK_POWER
UNIT_AURA
UNIT_COMBAT
UNIT_COMBO_POINTS
UNIT_DAMAGE
UNIT_FACTION
UNIT_FLAGS
UNIT_HEALTH
UNIT_HEALTH_FREQUENT
UNIT_HEAL_ABSORB_AMOUNT_CHANGED
UNIT_HEAL_PREDICTION
UNIT_MANA
UNIT_MAXHEALTH
UNIT_MODEL_CHANGED
UNIT_PORTRAIT_UPDATE
UNIT_POWER
UNIT_POWER_FREQUENT
UNIT_RANGEDDAMAGE
UNIT_RANGED_ATTACK_POWER
UNIT_RESISTANCES
UNIT_SPELLCAST_FAILED
UNIT_SPELLCAST_FAILED_QUIET
UNIT_SPELLCAST_INTERRUPTED
UNIT_SPELLCAST_SENT
UNIT_SPELLCAST_START
UNIT_SPELLCAST_STOP
UNIT_STATS
UNIT_TARGET
UNIT_THREAT_LIST_UPDATE
UNIT_THREAT_SITUATION_UPDATE
UPDATE_INVENTORY_ALERTS
UPDATE_INVENTORY_DURABILITY
UPDATE_MOUSEOVER_UNIT
UPDATE_SHAPESHIFT_COOLDOWN
UPDATE_SHAPESHIFT_FORM
UPDATE_SHAPESHIFT_USABLE
UPDATE_WORLD_STATES
VEHICLE_ANGLE_SHOW
VEHICLE_POWER_SHOW
VERHICLE_UPDATE
VIGNETTE_ADDED
VIGNETTE_REMOVED
WORLD_MAP_UPDATE
ZONE_CHANGED
  Reply With Quote
11-29-16, 04:22 PM   #7
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
The short of it is that /eventtrace or /etrace, which I knew about, or creating a frame and registering events you want to learn about are the only ways to discover the args.

And that means you have to do something in game that fires the events. Darn. I think /dump can print out APIs that currently don't care about; it would be nice to have something like that for events.
  Reply With Quote
11-29-16, 06:06 PM   #8
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Create an addon with a saved variable table, register for all events then feed events as keys and all the args into that table. Keep it running for a few months and you'll probably end up with most of them covered lol.
__________________
  Reply With Quote
11-29-16, 06:09 PM   #9
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Originally Posted by MunkDev View Post
Create an addon with a saved variable table, register for all events then feed events as keys and all the args into that table. Keep it running for a few months and you'll probably end up with most of them covered lol.
Crazy, I know, but I did think about doing that. Then my sanity returned
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Documenting events


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