Skip to main content
The GenericTrigger system handles all trigger types except aura triggers. It manages trigger registration, loading, and event handling for various game events.

Core Functions

Add

Adds a display and creates all internal data structures for all triggers.
GenericTrigger.Add(data)
data
table
required
The aura data structure containing trigger configuration

Delete

Deletes all triggers for a display ID.
GenericTrigger.Delete(id)
id
string
required
The display ID to delete

Rename

Updates all trigger information from old ID to new ID.
GenericTrigger.Rename(oldid, newid)
oldid
string
required
The old display ID
newid
string
required
The new display ID

LoadDisplay

Loads all triggers of a display ID.
GenericTrigger.LoadDisplay(id)
id
string
required
The display ID to load

LoadDisplays

Loads multiple displays and registers necessary events.
GenericTrigger.LoadDisplays(toLoad, loadEvent, ...)
toLoad
table
required
Map of display IDs to load
loadEvent
string
Optional event that triggered the load
...
any
Additional event arguments

UnloadAll

Unloads all triggers and clears all data.
GenericTrigger.UnloadAll()

UnloadDisplays

Unloads specific displays.
GenericTrigger.UnloadDisplays(toUnload)
toUnload
table
required
Map of display IDs to unload

Modernize

Modernizes all generic triggers in data to current format.
GenericTrigger.Modernize(data)
data
table
required
The aura data to modernize

Helper Functions

These functions are mainly for WeakAuras Options.

GetOverlayInfo

Returns a table containing the names of all overlays.
GenericTrigger.GetOverlayInfo(data, triggernum)
data
table
required
The aura data
triggernum
number
required
The trigger number
overlayInfo
table
Table of overlay names

CanHaveTooltip

Returns the type of tooltip to show for the trigger.
GenericTrigger.CanHaveTooltip(data, triggernum)
data
table
required
The aura data
triggernum
number
required
The trigger number
tooltipType
string
Type of tooltip (“spell”, “item”, “unit”, etc.)

GetNameAndIcon

Returns the name and icon to show in the options.
GenericTrigger.GetNameAndIcon(data, triggernum)
data
table
required
The aura data
triggernum
number
required
The trigger number
name
string
Display name for the trigger
icon
string
Texture path for the icon

GetAdditionalProperties

Returns a tooltip for the additional properties.
GenericTrigger.GetAdditionalProperties(data, triggernum)
data
table
required
The aura data
triggernum
number
required
The trigger number
tooltip
string
Tooltip text describing additional properties

GetProgressSources

Fills outValues with the potential progress sources.
GenericTrigger.GetProgressSources(data, triggernum, outValues)
data
table
required
The aura data
triggernum
number
required
The trigger number
outValues
table
required
Table to fill with progress sources

GetTriggerConditions

Returns potential conditions that this trigger provides.
GenericTrigger.GetTriggerConditions(data, triggernum)
data
table
required
The aura data
triggernum
number
required
The trigger number
conditions
table
Array of condition definitions

Event Scanning Functions

ScanEvents

Scans for matching triggers on a game event.
WeakAuras.ScanEvents(event, arg1, arg2, ...)
event
string
required
The event name
...
any
Event arguments

ScanUnitEvents

Scans for matching triggers on a unit-specific event.
WeakAuras.ScanUnitEvents(event, unit, ...)
event
string
required
The event name
unit
string
required
The unit token
...
any
Additional event arguments

CreateFakeStates

Creates fake trigger states for options preview.
GenericTrigger.CreateFakeStates(id, triggernum)
id
string
required
The display ID
triggernum
number
required
The trigger number

Trigger Counter

Trigger counters track event occurrences and can match specific counts or patterns.

CreateTriggerCounter

Creates a new trigger counter with optional pattern matching.
Private.ExecEnv.CreateTriggerCounter(pattern)
pattern
string
Cron-like pattern for matching counts (e.g., “2,5,6” or “2-6” or “2/3”)
counter
table
Counter object with methods:
  • Reset() - Resets count to 0
  • GetNext() - Increments and returns current count
  • SetCount(count) - Sets current count
  • Match() - Returns true if current count matches pattern

Examples

Basic Trigger Setup

-- Add a display with triggers
local data = {
  id = "MyAura",
  triggers = {
    {
      trigger = {
        type = "event",
        event = "PLAYER_ENTERING_WORLD"
      }
    }
  }
}

GenericTrigger.Add(data)
GenericTrigger.LoadDisplay("MyAura")

Event Counter Pattern

-- Match every 3rd event starting from the 2nd
local counter = Private.ExecEnv.CreateTriggerCounter("2-11/3")

-- This will match counts: 2, 5, 8, 11
counter:SetCount(2)
print(counter:Match()) -- true

counter:SetCount(5)
print(counter:Match()) -- true

counter:SetCount(3)
print(counter:Match()) -- false

Custom Event Handling

-- Scan for custom events
WeakAuras.ScanEvents("MY_CUSTOM_EVENT", "arg1", "arg2")

-- With unit events
WeakAuras.ScanUnitEvents("UNIT_HEALTH", "player")

See Also

Build docs developers (and LLMs) love