Minion Beta! - Help us test our new AddOn updater. Get it now!
Download
(12 Kb)
Download
Updated: 05-18-10 08:31 AM
Pictures
File Info
Updated:05-18-10 08:31 AM
Created:unknown
Downloads:1,705
Favorites:15
MD5:

Behaviors

Version: 1.03
by: Nexuapex [More]

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

v1.03
- Now works with client patch 3.3.3.
v1.02
- Now works with client patch 3.0.2.
v1.01
- 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.
v1.00
- Initial version.
Archived Files (1)
File Name
Version
Size
Author
Date
1.02
12kB
Nexuapex
10-14-08 08:10 AM


Post A Reply Comment Options
Unread 07-28-08, 07:56 PM  
0Blackmage0
A Chromatic Dragonspawn
 
0Blackmage0's Avatar
AddOn Author - Click to view AddOns

Forum posts: 192
File comments: 18
Uploads: 5
Simply Amazing

This is an awsome mod, and it came along at just the right time. Im just trying to learn lua coding in WoW and between this mod and the "WoWlua" mod (in the dev catagory) should make experimenting with the code much easyer.

Great Work!
__________________


0Blackmage0 is offline Report comment to moderator  
Reply With Quote
Unread 07-28-08, 08:07 PM  
Nexuapex
A Fallenroot Satyr
AddOn Author - Click to view AddOns

Forum posts: 25
File comments: 9
Uploads: 2
Re: Simply Amazing

Originally posted by 0Blackmage0
This is an awsome mod, and it came along at just the right time. Im just trying to learn lua coding in WoW and between this mod and the "WoWlua" mod (in the dev catagory) should make experimenting with the code much easyer.

Great Work!
Glad to hear it!
Nexuapex is offline Report comment to moderator  
Reply With Quote
Unread 07-29-08, 11:14 AM  
Eihen
A Kobold Labourer

Forum posts: 0
File comments: 2
Uploads: 0
hey! great add on! Really enjoying that innervate code that you have at the bottom!

Now i just need to learn LUA a bit more...

Behaviors = Macro on steriods!
Eihen is offline Report comment to moderator  
Reply With Quote
Unread 07-31-08, 09:37 AM  
Macniel
A Fallenroot Satyr
 
Macniel's Avatar
AddOn Author - Click to view AddOns

Forum posts: 26
File comments: 113
Uploads: 10
This AddOn looks very promising and very innovative
Macniel is offline Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: