Defining a new global variable or function that begins with a lowercase letter in a behavior places that variable or function in the behavior's environment, effectively making it local to that environment.
Certain functions bind properties to globals in your behavior's environment. The only ones that currently exist are cvar() and cvarbool(), which provide shorthand access to WoW's configuration variables. For example:
music = cvarbool "Sound_EnableMusic"
After that call, the music variable is bound to the current value of the "Sound_EnableMusic" configuration variable.
Certain functions, when called before a function definition, define triggers for that function. When any trigger's condition is satisfied, the associated function is executed. No triggers will fire when their behavior is disabled. For example:
trigger "load" function hello()
-- This function is called when the behavior is enabled.
trigger "unload" function goodbye()
-- This function is called when the behavior is disabled.
event "player regen (enabled, disabled)" function combat()
-- This function is called when the player enters or leaves combat.
If you define a function in your behavior with the same name as a global function, your defined function hooks (instead of replacing) the existing global function.
The function print(...) writes all of its parameters to the default chat frame.
trigger("names"[, ...]) • Causes the function to be executed when a given trigger or triggers are fired. The only triggers fired currently are "load" and "unload", when your behavior is enabled or disabled, respectively.
hook([table,] "names"[, ...]) • Causes the function to become a secure hook of the function(s) with the given name(s) on the specified table (by default, the global environment).
hookscript(obj or "name", "scripts"[, ...]) • Causes the function to become a secure hook of the specified handler(s) of the given frame.
event("names"[, ...]) • Causes the function to be executed when the given event or events are received.
slash("name") • Causes the function to become a slash command /name.
Any string argument of any trigger that can take a variable of arguments can contain a comma-separated list of values, and can also contained parenthesized expressions to an arbitrary depth. Examples:
left, right = MainMenuBarLeftEndCap, MainMenuBarRightEndCap
trigger "unload" function show()
Hide player names when you hide your interface:
names = cvarbool "UnitNameFriendlyPlayerName"
hookscript(UIParent, "OnHide") function hide() names = false end
hookscript(UIParent, "OnShow") function show() names = true end
Merge the Chat Reply and Re-Whisper keybindings:
lastTell = (name ~= "") and name or nil
if name and name ~= "" then
lastTold, timeout = name, GetTime() + 30
lastTold, timeout = nil, nil
hook "ChatFrame_ReplyTell(2)" function reply(frame)
if timeout and GetTime() > timeout then
lastTold, timeout = nil, nil
local name = lastTold or lastTell
if name then ChatFrame_SendTell(name, frame) end
Whisper the target of your Innervate spell (change "Innervate" to the name of any buff):
event "combat log event unfiltered"
function echo(_, what, _, _, src, _, name, dest, _, spell)
if what == "SPELL_CAST_SUCCESS" and spell == "Innervate" then
local srcIsMe = bit.band(src, 0xF) == 0x1
local destIsMe = bit.band(dest, 0xF) == 0x1
local destIsPlayer = bit.band(dest, 0xFC00) == 0x400
if srcIsMe and destIsPlayer and not destIsMe then
SendChatMessage("You have been innervated!", "WHISPER", nil, name)
- Now works with client patch 3.3.3.
- Now works with client patch 3.0.2.
- Can now enable/disable behaviors on a per-character basis.
- Added slash() trigger for registering slash commands.
- Added string parsing to simplify the addition multiple triggers at once.
- Initial version.