Beginning Lua with WoW Addons - The TOC File

The TOC File Format

    A TOC (table of contents) file contains metadata, or “data about data,” describing an addon along with a list of Lua and XML files to load. There are a few basic attributes like the name of the addon and the version of World of Warcraft it was made for. But it is also possible to define custom attributes and store arbitrary data in a TOC file.

    A typical TOC file is shown as below:

    There are two types of commands in this TOC file: lines starting with contain metadata. All other lines are files that will be executed to load the addon.We are defining the following metadata for our addon:

 ## Interface: 70300

    This tells the game that our addon is written for World of Warcraft 7.0.x. If this version number is lower than the current interface version, World of Warcraft will report that the addon is outdated or even incompatible.

 ## Title: HelloWorld

    This defines the name of our addon, so it will show up as “Hello, World!” in the list of installed addons.

 ## Title-zhCN: NIHAO,SHIJIE!

    An example of localization, this is a special line that will only be executed if you are using a Chinese client. It overwrites the old title we defined before, so our addon will show up as “NIHAO,SHIJIE!” in Chinese clients. You can append any locale to any metadata name to localize your addon. A locale consists of a language code followed by a country code, so "zhCN" stands for Simplified Chinese-China. The locale of English clients is always "enUs", even if you have the European version.

 ## Note: The Best "Hello,World" Addon!

    This additional infomation will be shown in the tooltip of the addon.

    There are many metadata attributes that are recognized by World of Warcraft.Shown as below.

Table: Available MetaData Attributes 

Metadata Description
Interface The interface vesion the addon is written for.
Title The name of the addon.
Notes More information about the addon.
RequireDeps

A comma-separated list of addons that are required for this addon.

The addon will load after all dependencies are loaded,and it won't load

if one of it's dependencies is missing or disabled.

OptionalDeps

A comma-separated list of addons that will be loaded before the addon

if they are installed and enabled.

LoadOnDemand

0 (default) or 1.A load-on-demand addon will not be loaded when logging

in.You can load the addon by calling LoadAddon(addon) in another addon.

LoadWith

Requires LoadOnDemand = 1.A comma-separated list of addons.The

addons will be loaded if one of these addons is loaded.

LoadManagers

A comma-separated list of addons.This will set LoadOnDemand to 1 if one

of the given addons is enabled.

SaveVariables

A comma-separated list of global variables that will be saved to \WTF\Acc-

ount\<accountname>\SavedVariables\<addon>.lua when logging out.

SaveVariablesPerCharacter

This does basically the same as SaveVariables,but it will save everything on

a per-character basis to \WTF\Account\<accountname>\<server>\<chara-

cter>\SavedVariables\<addon>.lua.

DefaultState

Either enabled or disabled.Determines whether the addons will be enabled

or disabled by default.

Secure

1 or 0.Secure addons are digitally signed by Blizzard.There is no way to get

such a signature at the moment,so this attribute can only be used by

Blizzard's addons.

猜你喜欢

转载自acetciacid.iteye.com/blog/2323925
toc