Alerts & Outputs
Overview
Configurable notification system. Alerts have multiple outputs (TTS, Sound, Voice). Used both by the Module system (module-level alerts) and by Monitors (per-rule-state alerts).
Files
core/alerts/alerts.lua— Alert + AlertOutput base classescore/alerts/outputs.lua— TTS, Sound, Voice output implementations
Alert Class
local alert = WowVision.alerts.Alert:new({ key = "myAlert", label = "My Alert" })
alert:addOutput({ type = "Sound", key = "sound", label = "Sound Alert", enabled = false })
alert:addOutput({ type = "TTS", key = "tts", label = "TTS Alert", enabled = false })
alert:fire({ text = "Something happened" })
Properties:
key— Unique identifier (immutable)label— Display labelenabled— Boolean, persistedoutputs— Array of AlertOutput instancesparameters— InfoFrame for UI configuration
Methods:
fire(message)— If enabled, fires all enabled outputs with messageupdate()— Calls update on all outputsaddOutput(info)— Add output (TTS/Sound/Voice)setDB(db)/getDefaultDBRecursive()— Database persistencesetEnabled(enabled)— Toggle alert
AlertOutput Class
Properties:
key,label,tag— IdentityshouldFire— Optional conditional functionenabled— Booleanparameters— InfoFrame for output-specific settings
Methods:
fire(message)— Check shouldFire, call onFireonFire(message)— Abstract, implemented by output type subclassesaddParameter(info)— Add configurable parameter
Output Types
TTS (Text-To-Speech)
alert:addOutput({
type = "TTS", key = "tts", label = "TTS Alert",
buildMessage = function(self, message) return message.text end,
interrupt = false,
})
Every such output has three settings: on/off, Priority Message (interrupts) and Voice. Voice
lists the game’s TTS voices and shows the one the output speaks with. Until the player picks
one it follows the Speech Voice setting (stored as classes.SPEECH_VOICE); a picked voice
speaks that output’s text in the speech queue like all other speech. Picking the Speech Voice
itself makes the output follow it again.
Sound
alert:addOutput({
type = "Sound", key = "sound", label = "Sound Alert",
getPath = function(self, message) return "Sound/WowVision/alerts/notification.mp3" end,
})
Voice
alert:addOutput({
type = "Voice", key = "voice", label = "Voice Alert",
getPath = function(self, message) return "Path", "directions/" .. message.dir .. ".mp3" end,
voicePack = "Matthew",
})
Firing Sequence
- Something triggers
alert:fire(message) - Alert checks
self.enabled - For each output: checks
output.enabledandshouldFire(message) - Calls
output:onFire(message)— type-specific action (speak, play sound, etc.)
Module Integration
local module = WowVision.base:createModule("myModule")
local alert = module:addAlert({ key = "myAlert", label = "My Alert" })
alert:addOutput({ type = "TTS", key = "tts", label = "TTS" })
-- Firing:
module:fireAlert("myAlert", { text = "Something happened" })
Module methods:
addAlert(info)— Creates Alert, stores inself.alertsfireAlert(alertKey, message)— Fires alert by keygetDefaultAlerts()— Returns default DB for all alerts- DB auto-bound in
setDBObj()—db.alerts[alertKey]
Monitor Integration
In the monitors system, alerts are attached to rule states via Alert fields:
AuraStateRule.info:addFields({
{ key = "applied", type = "Alert", persist = true,
alert = { key = "applied", label = "Applied" },
outputs = {
{ type = "Sound", key = "sound", label = "Sound Alert", enabled = false },
{ type = "TTS", key = "tts", label = "TTS Alert", enabled = false },
} },
})
The AlertField type lazy-creates Alert instances and links them to the database when setDB cascades through the rule.
Database Persistence
Alert:getDefaultDBRecursive()
├── alert.parameters:getDefaultDB()
└── outputs[]:getDefaultDB()
Alert:setDB(db)
├── parameters:setDB(db)
└── outputs[]:setDB(db.outputs[key])
Custom Output Parameters
output:addParameter({
key = "announceRaidMarker",
type = "Bool",
label = "Announce Raid Target Marker",
default = true,
})
-- Accessible as self.db.announceRaidMarker in buildMessage/shouldFire