Triggers are the core detection system in WeakAuras. They monitor game events and states to determine when your displays should appear, update, or hide.
Every display needs at least one trigger to function. Triggers define when and why a display becomes active.
Triggers generate states that contain information about what activated:
State Structure
Multiple States
state = { show = true, -- Whether to show display changed = true, -- State has changed name = "Spell Name", -- Spell/aura name icon = "path/to/icon", stacks = 5, -- Stack count duration = 30, -- Total duration expirationTime = time, -- When expires progressType = "timed", -- Custom properties based on trigger type}
Triggers automatically register for relevant game events:
-- Event registration in GenericTrigger.luaif data.events then for index, event in pairs(data.events) do loaded_events[event] = loaded_events[event] or {} loaded_events[event][id] = loaded_events[event][id] or {} loaded_events[event][id][triggernum] = data endend
Each active trigger registers for game events. Too many complex triggers can impact performance.
-- Add a new triggerGenericTrigger.Add(data)-- Load triggers for displayGenericTrigger.LoadDisplay(id)-- Unload all triggersGenericTrigger.UnloadAll()-- Scan for trigger matchesWeakAuras.ScanEvents(event, ...)
-- Get current trigger statelocal states = WeakAuras.GetTriggerStateForTrigger(id, triggernum)-- Check if trigger is activelocal active = states[""] and states[""].show