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.
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”.
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:
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!
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…
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?):
EH assigns each shown graphic a type. The types are:
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
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.
You must be logged in to post a comment.