Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia
Register
(Included examples of each type of file to make each section more similar)
Line 15: Line 15:
 
<div style="margin-left: 3%;">
 
<div style="margin-left: 3%;">
 
There are three primary types of files that you'll need to worry about with addon editing:
 
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.
+
* TOC File - This file is required for any addon. This is the file supplies WoW with information about your addon and what file are required for your addon to work.
  +
* LUA Files - This contains all the programing for your addon.
* 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.
+
* XML Files - This holds the layout of frames you have created for your addon.
   
 
===TOC File===
 
===TOC File===
 
<div style="margin-left: 3%;">
 
<div style="margin-left: 3%;">
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:
+
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: 20000
 
## Interface: 20000
Line 27: Line 27:
 
## Notes: This AddOn does nothing but display a frame with a button
 
## Notes: This AddOn does nothing but display a frame with a button
 
## Author: My Name
 
## 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
 
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]]
 
You can read more about what you need or can put in a TOC over at [[The TOC Format]]
Line 43: Line 34:
 
=== LUA Files ===
 
=== LUA Files ===
 
<div style="margin-left: 3%;">
 
<div style="margin-left: 3%;">
[[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.
+
[[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";
  +
this:RegisterEvent("VARIABLES_LOADED")
  +
end
 
</div>
 
</div>
   
 
=== XML Files ===
 
=== XML Files ===
 
<div style="margin-left: 3%;">
 
<div style="margin-left: 3%;">
XML files are used to specify what your UI will look like if you have one. Check out [[XML User Interface]] for details.
+
XML files are used to specify what 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 one:
  +
  +
Script file="MyAddon.lua"/>
  +
  +
<Frame name="MyAddon">
  +
<Scripts>
  +
<OnLoad>
  +
MyAddon_OnLoad();
  +
</OnLoad>
  +
</Scripts>
  +
</Frame>
  +
 
</div>
 
</div>
   

Revision as of 15:00, 28 November 2007

Template:Breadcrumb1

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 - This file is required for any addon. This is the file supplies WoW with information about your addon and what file 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

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: 20000
## Title : My AddOn
## Notes: This AddOn does nothing but display a frame with a button
## Author: My Name
myAddOn.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 specific purpose. Here's a short example of one:

function MyAddon_OnLoad()
	SlashCmdList["MyAddon"] = MyAddon_SlashCommand;
	SLASH_MYADDON1= "/myaddon";
	this:RegisterEvent("VARIABLES_LOADED")
end

XML Files

XML files are used to specify what 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 one:

Script file="MyAddon.lua"/>

<Frame name="MyAddon"> 
	<Scripts> 
		<OnLoad> 
			MyAddon_OnLoad();
		</OnLoad>
	</Scripts>
</Frame>

Slash Commands

The HOWTO: 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.