AceAddon-3.0

From WowAce Wiki
Jump to: navigation, search


AceAddon-3.0 is a basis for addon objects. It provides shortcuts for running code on startup, embedding libraries, and creating sub-addons known as modules.

AceAddon:NewAddon(name, [lib, lib, ...])

Creates and returns an addon object. name is a string identifying the addon. No two addons can have the same name. Each lib is a string containing the name of an existing, embeddable LibStub library.

If the addon has an :OnInitialize() method then that method is called upon ADDON_LOADED. If the addon has an :OnEnable() method then that method is called upon PLAYER_LOGIN and if the addon is ever enabled after being disabled. See "Events that fire during the loading process".

-- An addon named "Example" with the AceTimer API.
Example = LibStub("AceAddon-3.0"):NewAddon("Example", "AceTimer-3.0")

-- This will be run when the player enters the game.
function Example:OnEnable() message("Hello Cleveland!") end

AceAddon:GetAddon(name, silent)

Returns the addon named name. silent is a boolean that determines the behavior when an addon cannot be found — if it is true, then nil is returned; otherwise, AceAddon will error.