Every event the client fires on the bus and what each hands your handler, one family to a page. Subscribe with hafen.event():on(key, fn). The keys are a closed set.
hafen.event():on("MeterChanged", function(meter, session)
hafen.log():write(session:user() .. ": " .. tostring(meter:res()))
end)
| Page | Holds |
|---|---|
| Your addon and the sessions | Your addon being loaded, ticked and disabled. A character connecting, reaching the world, taking the screen and ending. |
| The world | A game object coming and going, what is attached to one, a click on an entity of your own. |
| The character and the rosters | Meters, buffs, food, study, equipment, action bar, wounds, the kin roster, quests, the map’s pins, the radial menu. |
| The chat | A channel appearing, going away or taking the tab, and a line landing in one. |
| The fight | An opponent joining a fight or leaving it, the numbers between you moving, the target changing, a manoeuvre used, an opening drawn and taken away, the combat row changing. |
Most events are one character’s (meters, buffs, food, study slots, equipment, action bar, wounds, roster, quests, radial menu, chat channels and lines, the fight). Each of those hands your handler the Session it was about as its last argument. function(meter, session) reads the bar that moved and the character it belongs to. session:user() is the account. Last, not first, so a handler that does not care declares no second parameter. There is a worked example in the guide.
| Events without a session | Why |
|---|---|
GobAdded, GobRemoved, GobOverlayAdded, GobOverlayRemoved, GobSdtChanged, GobOverlaySdtChanged |
A game object is the world’s, and each fires once for it (the world). |
SessionAdded, SessionEnteredWorld, SessionSelected, SessionRemoved |
The session is the payload. |
Load, Update, Disable |
Your addon’s own. One of it however many characters are up. |
MarkerChanged |
The recorded map is one database for the client. |
GhostClicked, SpriteClicked, ObjectClicked, PatchClicked |
A thing you put in the world is in it once, for whichever character looks at it. |
A widget is not a global fact, so there is no WidgetCreated. Name the widget with the selector a lookup uses:
hafen.session():current():ui():on("window[title=Cupboard]", "Added", function(window)
hafen.log():write(window:items():count() .. " items")
end)
fn receives the Widget. Added also covers what is already open, since registering scans the live tree, so an addon reloaded with the window up still sees it. Watching for a widget has the rules. Neither event is about visibility. At Removed the widget is a key to match, not something to read.
| Absent | Reason |
|---|---|
| Skills, credos, lore, crafting recipes, combat schools, minimap icon categories, movement speed | Change only on an explicit, infrequent player action: read on demand from their own section’s verbs. |
hafen.event():on("*", fn) |
Throws. Each bus key hands the fact itself: a Gob, a Meter, a Session, a list. A handler for all of them could not name its key. * is every message on a message stream, where the key set is open. |
hafen.event() — subscribing, and why the key set is closed.:info() copies out of a payload, shape by shape.hafen.session — the payload the session family hands you.hafen.timer — polling on your own schedule.