WoW:Getting started with writing AddOns
So You Want To Write an Addon
This article is designed to be a launching off point to the many points of helpful information that exist out there, as well as supplement that information.
Editing Tools
Before you can write any sort of code, you'll want to have a tool that lets you edit you 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 is recommended.
To review the list of tools and get one you'd like, head to the Lua editors page.
File Types
There are three primary types of files that you'll need to worry about with addon editing:
- TOC File - You'll have to have one of these. This is the file that instructs WoW in some basics about your addon and what other files you want loaded.
- LUA Files - You'll likely have at least one of these. These files are the actual programming language files.
- XML Files - You'll likely have at least one of these if you're making any graphical UI parts. This file is what graphical parts your addon has.
TOC File
As stated above, you'll have to have one of these. This is the file that instructs WoW in some basics about your addon and what other files you want loaded. Here's an example one:
## Interface: 20000 ## Title : My AddOn ## Notes: This AddOn does nothing but display a frame with a button ## Author: My Name ## eMail: Author@Domain.com ## URL: http://www.wowwiki.com/ ## Version: 1.0 ## Dependencies: Sea ## OptionalDeps: Chronos ## DefaultState: enabled ## SavedVariables: settingName, otherSettingName myAddOn.xml MyFrame.xml MyButton.xml
You can read more about what you need or can put in a TOC over at The TOC Format
LUA Files
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 specfic purpose.
XML Files
XML files are used to specify what your UI will look like if you have one. Check out XML User Interface for details.
Slash Commands
The HOWTP: Create a Slash Command page covers this pretty well.
A Basic UI Frame
Honestly, the XML User Interface page really does cover a lot of great basics.
SavedVariables
The HOWTO: Save Variables Between Game Sessions 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
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.