Ace2 Tutorial For Those Familliar With Ace1.x

From WowAce Wiki
Jump to: navigation, search

(Note this is not complete at all. This could probably do with some better formatting and extra content)


Intro

You're a developer, you've noticed just how awesomely awesome Ace2's looking, you're familliar with Ace 1.x and you need to know how to quickly get started with Ace2.

This tutorial will help you do that!

Setting up Ace2 for your addon

Obtaining Ace2

Before you can use Ace2, you need to get it and include it with your addon!

If your addon is on the SVN, it's as simple as adding each subdirectory at <a href="http://svn.wowace.com/root/trunk/Ace2/" class="external free" title="http://svn.wowace.com/root/trunk/Ace2/" rel="nofollow">http://svn.wowace.com/root/trunk/Ace2/</a> to your externals.

If not, just use a SVN client to checkout. (What is the SVN?)

Make sure you only include the modules you'll actually use

Loading Ace2

Easy. As simple as adding files to your addon's TOC.

AceLibrary\AceLibrary.lua
AceOO-2.0\AceOO-2.0.lua
AceConsole-2.0\AceConsole-2.0.lua
AceEvent-2.0\AceEvent-2.0.lua
AceAddon-2.0\AceAddon-2.0.lua
AceHook-2.0\AceHook-2.0.lua
AceDB-2.0\AceDB-2.0.lua
AceDebug-2.0\AceDebug-2.0.lua
AceLocale-2.0\AceLocale-2.0.lua
AceModuleCore-2.0\AceModuleCore-2.0.lua

Make sure that AceLibrary goes first and AceOO second, and that all Ace2 files are loaded before your addon's

Only files you're actually going to use should go in the TOC. The exceptions are AceLibrary and AceOO. AceLibrary's required by everything, AceOO by almost everything

Using Ace2

GetInstance-ing

What is GetInstance-ing? It's the successor to AceAddon:new()

Say goodbye to this:

MyAddon = AceAddon:new({
   name            = "MyAddon",
   description     = "A rather sexy example",
   version         = "1.3.37",
   releaseDate     = "2006-13-32",
   aceCompatible   = "103",
   author          = "Mr Foo",
   email           = "[email protected]",
   category        = "combat",
})

And say hello to this:

MyAddon = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0", "AceHook-2.0", "AceConsole-2.0")

Or at least something similar to that. The arguments to :new() should only be modules that you'll actually use. That example doesn't cover every module you can use e.g. AceDB isn't there.

Any other changes?

  • You must rename :Initialize(), :Enable() and :Disable() to :OnInitialize, :OnEnable() and :OnDisable()
  • The AceEvent-2.0 API is largely unchanged - Your old code can run unmodified. The only major difference is that you receive arg1, arg2, arg3 as proper arguments to your methods, not globals. There are also 2 new methods:
    • MyAddon:IsEventRegistered("event") (Returns a boolean stating whether your addon's registered that event)
    • MyAddon:TriggerEvent("event", arg1, arg2, and so on) (A nice way to do inter-addon communication by firing your own custom events)
  • The AceHook-2.0 API is largely unchanged, except that your hooks are stored in self.hooks rather than self.Hooks. Also, method hooking now pushes the object as the first argument.
  • As for AceDB-2.0, it's totally different from its previous incarnation.
  • Don't forget to check out the brand new functionality! See Ace2 for more.

Releasing your mods

Now that Ace2 is at the RC stage, you may release your addons to the major sites.

Don't forget that we have an SVN for you to use. Not only does it make life easier for you, it also allows advanced users to get bleeding edge stuff and give you feedback