WoW AddOn The idea of picking up any programming language can be daunting, and when you have to tie your program into someone else's APIs it can be nearly overwhelming. Creating your own AddOn
WoW AddOn

The idea of picking up any programming language can be daunting, and when you have to tie your program into someone else's APIs it can be nearly overwhelming. Creating your own AddOn will be a difficult process for novice coders, but the end satisfaction is worth it.

First Steps Edit

These first step detail what someone might do to get started writing AddOns for World of Warcraft for the first time.

What should I make Edit

Figure out what you want your AddOn to do. Don't try and get into the details too much, just decide what you want the overall goal to be. I usually start by asking myself these questions:

  • What's my end goal?
  • What information will I need from WoW for my AddOn to work?
  • Will I need to make custom frames?
  • Will I need to interact with Blizzard's frames?
  • Do I know the functions needed to do everything I want to do?

How do I make it Edit

Research the programming environment.

  • Learn the WoW UI language, Lua, by reading a few pages of the reference for the basic idea.
  • Learn the WoW UI API, World of Warcraft API and UI constructs, by reading a bit from each section.
  • Learn the basic structure, as detailed below, also skimming WoW AddOn reference page for structure.
  • Find a real but simple example, like from Curse, to get a basic idea of what's involved in a real AddOn.
  • Make a barebones test AddOn to do something simple, using the reference material described above.

The following sections help with some of the various aspects of completing these first steps.

Getting into the WoW API Edit

Getting information on how the WoW UI works is critical to making your AddOn function. The World of Warcraft API has a list of functions that will give you that information. These are your building blocks, and if you don't have a block you need (or thought you needed) then you'll have to find another way to get information for your AddOn. Don't be discouraged, as with any programming language there are many different ways to accomplish your goal, so keep looking until you find a way.

Getting the UI Source Code Edit

See also Extracting interface files and Viewing Blizzard's interface code.

You may want to extract the Blizzard interface files, where you can view all of the XML and Lua files that make the game's default UI work> This can be useful as example code and provides you with two introductory tutorials.

Enable the WoW "console" Edit

Note: the launcher now has an option to launch in console mode, which can be used instead.

This section helps open WoW with the console flag enabled to use the WoW console, necessary for extracting the WoW interface.

For Windows
  • Navigate to your WoW install directory, usually in 'C:\Program Files (x86)'.
  • Right-click the 'WoW.exe' file
  • Click 'Send to → Desktop (create shortcut)'
  • Navigate to, or look at, your Desktop
  • Right-click on your newly created shortcut
  • Select 'Properties', a new window will pop up
  • In the target line you need to add '-console' to the very end of the line it should look similar to this:
"C:\Program Files (x86)\World of Warcraft\Wow.exe" -console
  • Make sure to hit 'Apply', close the window and launch your created shortcut
For Mac OS X
  • Open '', located in '/Applications/Utilities'.
  • Paste the following command and press return:
Open "/Applications/World of Warcraft/World of" --args -console
  • WoW will launch
  • Note that the command was tested with WoW 5.0.5 on Mac OS X 10.8

Extract the API Edit

  • At the login page (before logging in) press the tilde (~) key (the key to left of the 1 key, labeled `~) to open the World of Warcraft console
    • Note: If this is not working, you can add your own temporary key mapping to access the console. First Log into the game, then enter the following slash command: /run SetConsoleKey("z"). This SetConsoleKey command key mapping will not persist after exting the game.
  • Type "exportInterfaceFiles code" or "exportInterfaceFiles art". Code is probably what you're looking for, you will notice the game will seem to lock up, or make a long pause, as it is exporting the files. This is normal. WoW will not render new frames while exporting the files. When complete the game will continue.
  • You can now find the current version of the stock UI files in the BlizzardInterfaceCode folder of your WoW directory.

Editing Tools Edit

Before you can write any sort of code, you'll want to have a tool that lets you edit your AddOn files. All AddOn files are plain text files, meaning even Notepad will do. You can also get LUA and XML specific text editors, which will highlight syntax for you, in turn making your coding a lot easier. To review the list of tools and get one you'd like, head to the Lua editors page.

File Types Edit

There are three primary types of files that you'll need to worry about with AddOn editing:

  • TOC File - This file is required for any AddOn. This is the file that supplies WoW with information about your AddOn and which files are required for your AddOn to work.
  • LUA Files - This contains all the programing for your AddOn.
  • XML Files - This holds the layout of frames you have created for your AddOn.

TOC File Edit

This is the file that instructs WoW in some basics about your AddOn and what other files you want loaded. Here's a short example of one:

## Interface: 70300
## Title : My AddOn
## Notes: This AddOn does nothing but display a frame with a button
## Author: My Name
# This is a comment. Interface: 60200 refers to WoW client version 6.2

You can read more about what you need or can put in a TOC over at The TOC Format

Lua Files Edit

Lua files contain functional pieces of code. You may choose to only have one of these or break up your code into multiple files for a specific purpose. Here's a short example of one:

function MyAddon_OnLoad()
    SlashCmdList["MyAddon"] = MyAddon_SlashCommand;
    SLASH_MYADDON1= "/myaddon";

XML Files Edit

XML files are used to specify the visual style of your frames. More importantly though a frame allows you to easily pass events to your Lua files. Check out XML User Interface for details. Here's a short example of an XML file:

<Script file="MyAddon.lua"/> 
<Frame name="MyAddon"> 

Start Coding! Edit

Start with the tutorials extracted by the Interface AddOn Kit. The HOWTOs here has a ton of great examples to help you learn. Don't be shy to dig through someone else's AddOn for help, just be sure to not steal code, and give credit where credit is due.

Beware Lua functions and variables are globals by default and are directly visible to the other addons. If authors blindly use simple and common names, like:

addonEnabled = true;
function GetArrowsCount()

an addon will easily conflict with variables of the same name from other addons or from the Blizzard interface. Instead, you should write your addon more like a Lua module: place all the data and functions in a single global table, named after the addon, and use local declarations otherwise (no other globals), like:

MarksmanAddOn = { };              -- about the only global name in the addon
local addonEnabled = true;        -- local names are all ok
function MarksmanAddOn:GetArrowsCount()
  ...                             -- function is now inside the global table
MarksmanAddOn.arrowsCount = MarksmanAddOn:GetArrowsCount()

For large add-ons this can get complicated, and the current version of Lua doesn't offer much to help. Use a full, clear, name for the global table, and assign a shorter name in your .lua files, like:

local mod = MarksmanAddOn;

-- then you can write
mod.arrowsCount = mod:GetArrowsCount()

Other then the global table for the addon, you may still need globals for the saved variables and the addon slash commands (see below) if you have any.

Slash Commands Edit

A slash command is one way for the user to interact with your AddOn. These will be the easiest way for a beginner to let the user supply command and change options. The HOWTO: Create a Slash Command page covers this pretty well.

A Basic UI Frame Edit

The XML User Interface page covers a lot of a great basics.

SavedVariables Edit

The Saving variables between game sessions article covers the key points. For folks new to AddOns but not other programming languages, just bear in mind that:

  • The SavedVariables is only read from on UI loading, not real time, and only saved to on UI unloading. This will generally be from a user logging in or logging out.
  • Basically, WoW makes a SavedVariables file for you named after your AddOn. You only get to specify in your TOC *which* variables get saved into that file.

Localization Edit

It's a good idea to plan from as early as possible to have your AddOn be localizable, even if you yourself only speak one language. Review this great article for some things to think about: HOWTO: Localize an AddOn.

External links Edit

Note: This is a generic section stub. You can help expand it by clicking Sprite-monaco-pencil Edit to the right of the section title.