Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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 classes
  • core/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 label
  • enabled — Boolean, persisted
  • outputs — Array of AlertOutput instances
  • parameters — InfoFrame for UI configuration

Methods:

  • fire(message) — If enabled, fires all enabled outputs with message
  • update() — Calls update on all outputs
  • addOutput(info) — Add output (TTS/Sound/Voice)
  • setDB(db) / getDefaultDBRecursive() — Database persistence
  • setEnabled(enabled) — Toggle alert

AlertOutput Class

Properties:

  • key, label, tag — Identity
  • shouldFire — Optional conditional function
  • enabled — Boolean
  • parameters — InfoFrame for output-specific settings

Methods:

  • fire(message) — Check shouldFire, call onFire
  • onFire(message) — Abstract, implemented by output type subclasses
  • addParameter(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

  1. Something triggers alert:fire(message)
  2. Alert checks self.enabled
  3. For each output: checks output.enabled and shouldFire(message)
  4. 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 in self.alerts
  • fireAlert(alertKey, message) — Fires alert by key
  • getDefaultAlerts() — 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