EventHorizon Course 3: Pimping EH

In the previous two entries, we covered what EventHorizon is and does, and what it doesn’t do. If you’ve been following this blog, you’ve likely already used (or just started using) EH. And, if you’re like me, you’re probably wondering where all the options are at.

Lua: Your Friendly Neighborhood Scripting Language

All of EventHorizon’s configuration is done through Lua, which is the language of WoW’s addons. Before we go rummaging through the config files, you’ll probably want to know some of Lua’s absolute basics.

I’ll skip the lengthy introductions and head straight for the relevant portions. First, some jargon.

A note on all of this: Lua is case sensitive. If you miss capitalizing a letter, Lua will spew an error at you.

A comment, signified by a double-dash ( ), is a line or bit of text that is not executed by the interpreter (in this case, WoW). Comments give you the ability to let yourself and everyone else know what a particular chunk of code does.

Comment blocks are multiple-line comments, signified by a leading double-dash and double-bracket ( –[[ ) and ending with another set of double brackets ( ]]– ). Note that the tailing comment dashes aren’t necessary, but it’s not a bad idea to write them in.

A local is a portable, named, re-assignable chunk of information which is only used within the function or file it was created in. More on how they’re used in a second.

A single = sign sets a chunk of information to something else.
A double == sign checks if one chunk of information is an exact match to another.
A tilde followed by a single = sign ( ~= ) checks if a chunk of information does not match with another.

local X = “Foo!” – Assigns X as a string
local Y = X – Assigns Y to X’s value
local Class = UnitClass(‘player’) – A WoW function that checks the class of a unit. This local will end up reading “PRIEST” if you’re playing one, “DEATHKNIGHT” if you’re on your DK, etc.
local Priest = UnitClass(‘player’) == ‘PRIEST’ – A little more complicated, checks the player’s class and assigns “Priest” as the string as “PRIEST”  if playing one.
local NotPriest = UnitClass(‘player’) ~= ‘PRIEST’ – Same thing in reverse, if you’re not playing a Priest it’ll assign NotPriest as your class’s name.

A table (Anyone who’s written in C/C++ likely prefers calling them arrays) is a list of data, declared in the same fashion as a local but using curved braces ( { and } ) to contain its information. Tables have all sorts of uses – Most of EH’s settings are stored in one giant table named EventHorizon.

Tables may be indexed or iterated. An indexed table can be described as a table that contains a bunch of locals. An iterated table is pure data, without named indexes. To clarify:

local Table = {“This”, “is”, “an”, “iterated”, “table”} – I’ll give you three guesses, first two don’t count. Note the commas separating everything.
local Table2 = { – An indexed table.
foo = 1,
bar = “String!”,
rawr = {“Another”, “table!”},
class = UnitClass(‘player’), — Yep, you can call functions in tables too.
} – The table only ends when its matching curved bracket appears.

Tables can be accessed in quite a few ways. The easiest is when using an indexed table, calling the entry by the index name. You may also call them by their iteration, which is explained below.

local Iterated = {1, 2, 3, 4, “Foo”, “Bar”}
local Indexed = {
foo = “lol”,
bar = “haithar”,
table = {“can has”, “cheezburger”}
number = 1, – Note: A number cannot be used as a table index.
number2 = 2, – This is because of table iteration. Long story.
}

– First, let’s call some stuff in the iterated table. The best way of doing this is via square braces, though there are other ways. Again, we cannot assign a number as a local, so we’ll be spelling out the numbers as we assign them.
local One = Iterated[1] – 1
local Two = Iterated[2] – 2
local Three = One + Two – Yes, you can do that, and yes, the result is 3.

– Next up we’ll call some things from the indexed table. Indexed tables are a little easier to use in some respects, and harder in others. Mix and match methods as you please, it’s flexible stuff.
local Foo = Indexed.foo – Called by name.
local FooToo = Indexed[foo] – Those square brackets really come in handy, this does the exact same thing. However, if “foo” is declared as a local…
local String = “foo”
local FooThree = Indexed[String] – …then the local will call that portion of the table.
local FooIt = Indexed[1] – Called by iteration. This isn’t generally useful for indexed tables, but can come in handy. See why a table index cannot be a number now?
local Table = Indexed.table — Our Table local now reads {“can has”, “cheezburger”}.
local TableOne = Indexed.table[1] – “can has”…
local TableTwo = Indexed.table.2 – “cheezburger”.

Using All That In EH

If you don’t already have it installed, it would be a very good idea to snag Notepad++ (NPP) and start using it from here on out. Lua is a very simple and easy to learn language, but if you’re trying to use the Windows Notepad or (*shudder*) WordPad to edit EventHorizon’s config files… it won’t be. NPP is free and open source software that uses syntax highlighting to make what you’ll be doing much, much easier, among other things.

I’ll assume from this point on that you:

  • Know where WoW is installed (I have mine in D:\Programs\WoW\, for example)
  • Know where EventHorizon is installed (within your WoW directory, Interface/AddOns/EventHorizon).
  • Know how to open a file with Notepad++ (rightclick a .lua file, you’ll see the option in there).
  • Have file extensions enabled in Windows Explorer, or at least know how to see and change them.

EventHorizon comes with the following files:
EventHorizon.lua contains EH’s core code. No user should ever need to touch this file.
EventHorizon.toc tells WoW which .lua files to load and run. Again, no user should ever need to touch it.
config.lua contains EH’s default settings and comments with usage information.
changelog.txt is a running tally of the changes made to EH over its lifespan. It makes for a good read, believe it or not.
Smooth.tga is the texture used in EH by default.

There’s one extra file that EventHorizon will load, when it’s present: myconfig.lua.

Myconfig acts as a second config.lua. Anything put in here will overwrite settings in the original config. And, since it’s not included with EventHorizon’s releases, it’s safe to assume that it will never be overwritten by a new version. This is good for everyone – myconfig.lua can be shared as you please, will stick around every time you update EH to the latest version, and can have as many or as few options as you like.

So, let’s create a copy of config.lua within EH’s directory, rename the copy to myconfig.lua, and open it up in Notepad++.

The first line of any config file should be this:

local config = EventHorizon.config

This tells the file that any time you type “config” you’re actually changing EventHorizon’s internal configuration table.

Next you’ll notice a bunch of locals assigning plain-text names to class calls. We’ll cover usage of these soon.

Now, on to the settings that EH uses!

  • recalculate (Default = true) tells EH to adjust DoT and HoT ticks as they fire. This option will be removed with the WoW Patch 3.3 update.
  • past (Default = -3) is the number of seconds to track in the past section of the window. This needs to be a negative number for technical reasons.
  • future (Default = 12) is the number of seconds to track in the future section of the window. This needs to be a positive number. EH’s time scale is judged from this – A larger number will result in shorter gaps between DoT ticks, slower-moving bars, etc. If you find that the default seems to cover too short or too long of a time span, try adjusting this. I used 30 seconds for quite a while myself.
  • spacing (Default = 0) is the number of pixels between bars on the EH window. This is purely cosmetic. Adjust if you’d like more room between the bars or to match your UI layout.
  • scale (Default = 1) is the actual UI scale of the EH window. A value of 1.5 will enlarge the window by 50%, a value of 0.75 will shrink it by 25%.
  • height (Default = 18) is the height in pixels of a single bar. EH has no limit to its size, so there is no way at present to directly set the height of the window – The actual window height is ((height + spacing) * the number of bars)*scale.
  • width (Default = 150) is the width in pixels of the EH spell bars. The spell icons add the bar’s height to its width. The actual width of the frame is (width + height)*scale.
  • anchor (Default = {“TOPRIGHT”, “EventHorizonHandle”, “BOTTOMRIGHT”}) is a somewhat complex field that needs a little extra explanation. WoW’s frame system is based completely on anchors, and this sets EH’s anchor accordingly.
    Valid points are LEFT, RIGHT, TOP, BOTTOM, CENTER, TOPLEFT, TOPRIGHT, BOTTOMLEFT, BOTTOMRIGHT. These points are the edges (or absolute center) of the respective frames. TOPLEFT is the absolute top left corner of the frame, for example.
    Knowing this, the syntax is {“Frame’s Point to Anchor”, “Frame to Anchor to”, “Anchor Frame’s Point”, offsetX, offsetY}. In the default, we’re anchoring the TOPRIGHT corner of EventHorizon’s frame to the BOTTOMRIGHT corner of EventHorizon’s handle with no offset.
    To keep EventHorizon movable ingame, it needs to be anchored to “EventHorizonHandle”, a little draggable button that’s created only when it’s needed.
    If you don’t feel the need to move EH, say if you’ve got a very specific UI layout, you can anchor the frame to just about anything else. Wimpface anchors his to his character’s unitframe. I anchor mine to my target’s. In these cases, the drag-handle isn’t even created and the frame is completely immobile.
    To place the frame directly at a point of the screen, use “UIParent” as the anchor. A few examples are in config.lua to give a better idea of how to do all this.
  • texturedbars (Default = true) tells EH to use a given texture. If texturedbars isn’t present (or is set to nil) EH will use solid colors as its bars instead.
  • texturealphamultiplier (Default = 2) Textures don’t have the contrast that solid colors do in a transparent environment. This field multiplies the opacity of any bars that use a texture. If the bars seem too dim or too bright, raise and lower this number until it feels right.
  • backdrop (Default = true) tells EH to draw a background under its bars. If you don’t feel the need for a background or prefer to use something like kgPanels to set a backdrop yourself, remove the line or set it to nil.
  • iconborder (Default = false/nil) tells EH whether or not to draw WoW’s built-in border around the spell icons. If you’re using the default backdrop with a little spacing between the bars, this can be a nice effect.
  • castLine (Default = true) adds a line to the end of any spellcast or channeled cast over 1.5 seconds, extending vertically across the frame. This line should be as accurate as the cast bar itself and seems to help quite a bit for any cast longer than the GCD. Uses the ’sent’ indicator coloring for technical reasons. Remove or set to anything other than ‘true’ to disable if you dislike it.
  • gcdstyle (Default = ‘line’) Valid options are ‘line’, ‘bar’, or false/nil. This option sets the Global Cooldown indicator accordingly: ‘line’ draws a thin line that looks like the Now Line for the GCD. ‘bar’ draws a much more visible bar vertically across the window. Setting this to nil or false will completely disable GCD tracking, saving a little CPU.

Short interlude: Coloring.

EventHorizon uses a table-based coloring system. Each color table has four values: {Red, Green, Blue, Alpha}. These entries have a minimum of 0, and a maximum of 1. These do not need to be whole numbers, you can use as many decimal places as you like. The Alpha is simply the opacity of a color, how transparent it is. A short list of common colors with alpha values omitted:

white: {1, 1, 1}
red: {1, 0, 0}
green: {0, 1, 0}
blue: {0, 0, 1}
yellow: {1, 1, 0}
orange: {1, 0.5, 0}
purple: {1, 0, 1}
pink: {1, 0, 0.5}

Math and fractions may be used as well within the table, as such:

red by 255: {255/255, 0/255, 0/255}
teal with some extra blue: {0, 199/255, 1}

Continuing on…

  • gcdcolor (Default = {1,1,1,0.5}) sets the color of the GCD bar or line. Use the information just above to see how this works.
  • bartexture (Default = “Interface\\Addons\\EventHorizon\\Smooth”) sets the texture used for all of EH’s graphics. Note that SharedMedia is loaded as an optional dependency of EH, meaning that its textures will be available to use as long as you know their paths. Better SharedMedia support is planned sometime for a future release, which would allow you to simply provide the texture’s name.
  • barbgcolor (Default = {1,1,1,0}) Note: The default has a color, but it’s completely transparent. EH creates a background for each bar (using the same texture as the bar) using this color. If you decide not to use a backdrop for EH at all, it may be a good idea to adjust this as well.
  • bg (Default = “Interface\\ChatFrame\\ChatFrameBackground”) sets the texture used for EH’s backdrop frame.
  • border (Default = “Interface\\Tooltips\\UI-Tooltip-Border”) sets the texture used for the backdrop frame’s border. SharedMedia includes a couple on its own, I also have a few that I can send at request. Note that this does not affect the spell icon borders.
  • bgcolor (Default = {0,0,0,0.6}) sets the color of the backdrop.
  • bordercolor (Default = {1,1,1,1}) sets the color of the border.
  • inset (Default = {top = 2, bottom = 2, left = 2, right = 2}) is an advanced setting that adjusts how many pixels the backdrop’s texture is adjusted by to account for its border. Tweak as needed if you change your backdrop.
  • padding (Default = 3) allows the backdrop to grow beyond EH’s actual frame size in pixels. The default extends 3 pixels past EH’s edges, for example. Adjust as you see fit if you change your backdrop and border.
  • edgesize (Default = 8) sets the thickness of the backdrop’s border. The optimal value for this depends on the border you choose and your UI in general.

That covers the standard settings. Notice that I’ve been pretty much following the layout of config.lua. If you scroll down a bit in the file you’ll see the color settings.

EH handles coloring for bars and bar segments on an individual basis, allowing you to set different colors for each type of information shown. Aside from setting the coloring manually via RGB values, you may also class-color any or all of these.

To do this, EventHorizon uses two extra config values not normally listed in config.lua (You knew I was gonna leave something out in the config, right?):

  • classburn (Default = 0.7) is the degree of which a class’s color is automatically darkened. Within the defaults, this setting is not used at all and is basically a failsafe (you’ll see why in a moment). It may still be manually set, and can be a value over 1 if desired.
  • classalpha (Default = 0.3) is the default opacity of a class-colored bar. Again, this isn’t used within the default config and is there mainly as a failsafe.

EH assigns each shown graphic a type. The types are:

  • sent is the marker lines drawn when a skill usage has been attempted and sent to the server. This does not mark the actual start of a cast or skill usage. This value is also used for the vertical casting line, marking the finish of casts over 1.5 seconds. (Default is class colored)
  • tick is the color of the little lines drawn indicating when a DoT or HoT spell will heal or do damage. (Default is class colored)
  • casting is the color of the cast and channel bars. (Default is green)
  • cooldown is the color of any cooldown lines. (Default is white)
  • debuffmine is the color of the debuffs that you have personally cast. (Default is class colored)
  • playerbuff is the color of the buffs that you have personally cast. (Default is class colored)
  • debuff is the color of anything that is tracked but not cast by you. For example, if playing as a Feral Druid with an Arms Warrior in the group, your Mangle bar may display the Warrior’s Trauma debuff as well. (Default is your class color, darkened by 50%)
  • default is unlisted in config.lua but may still be modified. This color is a fallback that is used in any case where EH can’t decide what’s going on. It isn’t seen in normal gameplay and its usage rests in debugging. (Default is pure white at 100% alpha)

Now that we know what can be colored, how do we do it?

The color table is stored outside of EventHorizon’s standard config: EventHorizon.colors. This table can be changed as a whole or piece by piece. Config.lua prefers piece by piece, and the defaults may be found at the bottom of the file.

Coloring may be done manually via {Red, Green, Blue, Alpha} or automatically via class coloring. The method of class coloring a bar is simple enough: Tell EH the bar is colored, and optionally add in burn and alpha.

local c = EventHorizon.colors
c.casting = {0,1,0,0.3}
c.debuff = {true,0.5,0.3}

The casting color is manually set to green, 30% opacity (since the opacity is multiplied if using textured bars, this is usually 60% opacity).

The debuff line reads exactly like this: Class colored (true instead of a number), 50% burn (the class’s color values are multiplied by 0.5), 0.3 alpha (30% opacity, again modified for textured bars).

If c.debuff is set simply to {true}, it will be class colored and use config.classburn and config.classalpha to fill in the blanks.

But wait. The default values for the other fields are a lot more complicated!

c.debuffmine = {true, Priest and 0.7 or 1, 0.3}

Remember those locals that were declared at the top of config.lua? This is where they really shine. The debuffmine entry reads literally as: “Class colored, burn to 0.7 if playing a Priest or 1 otherwise, 0.3 alpha”. This can be wrapped in parenthesis and even expanded if we like, as such:

c.debuffmine = {true, (Priest and 0.7) or 1, 0.3}
c.debuffmine = {true, (UnitClass(‘player’) == Priest and 0.7) or 1, 0.3}

c.debuffmine = {true, 1, 0.3}
if UnitClass(‘player’) == “PRIEST” then
c.debuffmine[2] = 0.7
end

There’s a lot of ways to do it. Since the Priest color is pure white, it’s darkened a bit to give cooldowns some contrast from buffs and debuffs. If you want to make Priests not use class coloring at all, you can do that in a few ways as well:

– Using inline conditions as before:
c.debuffmine = {(Priest and 0) or true, (Priest and 0.3) or 1, (Priest and 1) or 0.3, Priest and 0.3} – Reads {true, 1, 0.3} for everyone else, but Priests read it as {0, 0.3, 1, 0.3}.

– Or we can overwrite it using an if/then statement.
c.debuffmine = {true, 1, 0.3}

if Priest then – We’ll use our locals this time, this reads as “if UnitClass(‘player’) == ‘PRIEST’ then”
c.debuffmine = {0, 0.3, 1, 0.3}
end

In Closing

EventHorizon has many ways that you can customize it. This course has only scratched the surface – Using the config/myconfig system, you can turn EH into everything from a combat monitor to a buff watcher to a pure cooldown tracker. In the next course we’ll be covering everything related to spell configuration. Stay tuned.

Previous – EventHorizon Course 2: What EH Is Not
Next – EventHorizon Course 4: Mucking With the Class Config

You can download EventHorizon here.
If you enjoy the addon, remember that donations are what keeps it alive and evolving. I no longer play the game any more than necessary for testing purposes, and cannot spare the money to keep my WoW account running for that purpose alone.

local FooThree = Indexed[foo] – Those square brackets really come in handy.
Posted by Taroven   @   7 November 2009

Like this post? Share it!

RSS Digg Twitter StumbleUpon Delicious Technorati Facebook

2 Comments

Comments
Trackbacks to this post.
Leave a Comment

You must be logged in to post a comment.

Previous Post
«
Next Post
»
Powered by Wordpress   |   Lunated designed by ZenVerse