AddonLoader

From WowAce Wiki
Jump to: navigation, search
Summary
Addon Loader
Loadmanager for AddOns
TOC 2.4 (20400)
Authors Ammo, Cladhaire, Joshborke
Details
Version 2.0
Credits Nymbia, Mikk for the original AddonLoader
Links
Betas Ace SVN Zip
Changelog FishEye

AddonLoader is a load manager, which will load up addons based on conditions that they specify. It replaces ForkliftGnome.

Usage (as a player)

Simply having AddonLoader present should cover your needs. There are some options that can be accessed through /addonloader for overriding an addon's load condition.

Usage (as a developer)

Special Fields

## X-LoadOn-Events: UNIT_SPELLCAST_START, UNIT_MANA
## X-LoadOn-UNIT_SPELLCAST_START: if arg1 == 'player' then AddonLoader:LoadAddOn('MyAddOn') end 
## X-LoadOn-UNIT_MANA: if arg1 == 'player' then AddonLoader:LoadAddOn('MyAddOn') end 

Specify events to register for. You must specify event reaction code for each event.

## X-LoadOn-Hooks: GameTooltip_SetDefaultAnchor, ChatFrame_OnEvent

Specify functions that are to be securely hooked. Other than that, works like Events above.

## X-LoadOn-Execute: ChatFrame1:AddMessage('MyAddOn is present, but not yet loaded')

This code will execute on login regardless of if the addon is loaded or not. Use this if you need to specify complicated loading circumstances like function hooks. Note that toc fields are limited to about 1000 characters, if you must go over that amount, use X-LoadOn-Execute2 etc. Multiples get concatenated together and executed as one.

## X-LoadOn-Slash: /myaddon, /myadd

This specifies a slash command to register when your addon is not loaded. When the command is used by the player, your addon will be loaded, then the typed command will be issued again, so that options can be accessed if your addon's load condition hasn't yet fired.

## X-LoadOn-LDB-Launcher: Interface\AddOns\myAddon\icon
## X-LoadOn-LDB-Launcher: Interface\AddOns\myAddon\icon myAddonLauncher

This works similar to the slash loader, except with LDB launchers. AddonLoader will create an LDB launcher for your addon and set it's OnClick action to load your addon, then call the new OnClick handler your addon creates. This also means your addon must handle the LDB dataobj carefully, to ensure it is declared correctly for users with and without AddonLoader installed.

local ldb = LibStub:GetLibrary("LibDataBroker-1.1")
local dataobj = ldb:GetDataObjectByName("myAddonLauncher") or ldb:NewDataObject("myAddonLauncher", {type = "launcher", icon = "Interface\\AddOns\\myAddon\\icon"})
dataobj.OnClick = function(self, button) dosomethingonclick(button) end

The second arg is optional, if not present your addon's name will be used for the dataobject name. Also note that texture paths in the TOC use "\" while paths declared in lua must use an escaped "\\"

Load Conditions

## X-LoadOn-<tag>: <value(s)>
Tag Value(s) Description
Always true Load the addon unconditionally, use this to allow users to specify override behavior.
Always delayed Load the addon unconditionally, after the player has entered the world. Addons flagged delayed will get loaded sequentially on a timer, thereby reducing initial load time.
AuctionHouse true Load the addon when you go to the auction house.
Arena true Load the addon when you zone in to an arena.
Bank true Load the addon when you open your bank.
Battleground true Load the addon when you zone in to a battleground
Class Priest, Paladin, Druid Load the addon if the player is one of the specified classes. Note: only use English class names, comma-separated
Combat true Load the addon when you enter combat.
Crafting true Load the addon when the enchanting or tradeskilling frames are opened.
Group true Load the addon when you join a party or raid.
Guild true Load the addon if you are guilded.
Instance true Load the addon when you enter any PvE instance.
Level 35 Load the addon if the player is exactly level 35.
Level 25- Load the addon if the player is under or at level 25.
Level 56-60 Load the addon if the player is between 56 and 60 (inclusive)
Level 65+ Load the addon if the player is at or above level 65.
Mailbox true Load the addon when you open the mailbox.
Merchant true Load the addon when you're at a merchant.
NotResting true Load the addon when you aren't resting.
PvPFlagged true Load the addon when you are PvP flagged.
Raid true Load the addon when you join a raid.
Resting true Load the addon when you're resting.
Zone Duskwood, Stranglethorn Vale Load the addon when the player is in one of the specified zones. Use english zone names only, comma-separated