Tweak your interface's behavior in-game using shorthand Lua. Type /behaviors in-game to bring up a list of Lua snippets. Each snippet (or behavior) can be enabled and disabled independently.
This add-on requires a certain amount of Lua knowledge. Feedback is greatly appreciated.
Features:
- 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:
Code:
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:
Code:
trigger "load" function hello()
-- This function is called when the behavior is enabled.
end
trigger "unload" function goodbye()
-- This function is called when the behavior is disabled.
end
event "player regen (enabled, disabled)" function combat()
-- This function is called when the player enters or leaves combat.
end
- 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.
- Supports For All Indents And Purposes for syntax coloring and indenting.
Trigger Functions:- 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:
- "foo, bar" → "foo", "bar"
- "foo, bar(baz)" → "foo", "bar", "barbaz"
- "foo, bar (baz, foo(bar))" → "foo", "bar baz", "bar foo", "bar foobar"
Example Behaviors:- Hide the gryphons on the default main bar:
Code:
left, right = MainMenuBarLeftEndCap, MainMenuBarRightEndCap
trigger "unload" function show()
left:Show() right:Show()
end
left:Hide() right:Hide()
- Hide player names when you hide your interface:
Code:
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:
Code:
function ChatEdit_SetLastTellTarget(name)
lastTell = (name ~= "") and name or nil
end
function ChatEdit_SetLastToldTarget(name)
if name and name ~= "" then
lastTold, timeout = name, GetTime() + 30
else
lastTold, timeout = nil, nil
end
end
hook "ChatFrame_ReplyTell(2)" function reply(frame)
if timeout and GetTime() > timeout then
lastTold, timeout = nil, nil
end
local name = lastTold or lastTell
if name then ChatFrame_SendTell(name, frame) end
end
- Whisper the target of your Innervate spell (change "Innervate" to the name of any buff):
Code:
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)
end
end
end