Wowpedia

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

READ MORE

Wowpedia
m (Removed excess whitespace from title tag for consistency)
mNo edit summary
(21 intermediate revisions by 11 users not shown)
Line 1: Line 1:
 
{{uitech}}
 
{{uitech}}
'''.toc files''' contain information about a particular addon (such as its name, description, saved variables, etc), as well as instructions on how the addon should be loaded by the client (for example, the order in which lua and xml files should be loaded). The file must be present, and have the same name (plus extension) as its parent folder for the addon to be recognized by the client.
+
'''.toc''' (Table of Contents) files contain information about a particular addon (such as its name, description, saved variables, etc), as well as instructions on how the addon should be loaded by the client (for example, the order in which lua and xml files should be loaded). The file must be present, and have the same name (plus extension) as its parent folder for the addon to be recognized by the client.
  +
  +
== Basic rules ==
  +
  +
The game client searches each subfolder of <code>...\Interface\AddOns\</code> (only one level deep) for .toc files having the same name as the subfolder. This .toc file has instructions of the following format:
  +
* Metadata printed as <code>## TagName : tagValue</code>, where whitespace is trimmed (except at the start of a line)
  +
* Comments printed as <code># this is a comment</code> ignored by the client
  +
* A list of files to be loaded as <code>myFile.xml</code> or <code>subfolder/anotherFile.lua</code>
   
== A typical .toc file ==
 
Suppose you were writing addon called "Godot". In order to get the client to recognize your addon, you'd have to create the <code>World of Warcraft\Interface\AddOns\Godot</code> folder, and a <code>Godot.toc</code> file within it. The contents of the .toc file could be:
 
 
## Interface: {{API LatestInterface}}
 
## Interface: {{API LatestInterface}}
 
## Title: Waiting for Godot
 
## Title: Waiting for Godot
## Notes: "Nothing to be done."
+
## Notes: Nothing to be done.
 
## Version: 4.2
 
## Version: 4.2
 
Vladimir.xml
 
Vladimir.xml
 
Estragon.lua
 
Estragon.lua
  +
libs/SomeEmbeddedLibrary.lua
  +
 
# This is a comment
   
  +
== File load order ==
There are two main line types: lines beginning with "## " designate a .toc tag, which contains information that may be used by the client; for instance, "## Title : Waiting for Godot" communicates to the client that the addon should be called "Waiting for Godot" in the addons list, rather than simply "Godot" as its folder name would imply. The lines without this prefix specify the files that should be loaded by the client when this addon is run: in this case, the Vladimir.xml file in the addon's folder should be loaded before Estragon.lua in the same folder.
 
   
  +
The .toc file provides an ordered list of files to be loaded by the client. In the earlier example:
== Official Tags ==
 
  +
* Vladimir.xml loads first, and is in the same folder as the .toc file
There are a number of "official" (either used by the client or explicitly allowed access to via {{api|GetAddOnMetadata}}) .toc tags. The tags can be added to a .toc file in any order in the following format:
 
  +
* Estragon.lua loads second, and is in the same folder as the .toc file
## TagName : tagValue
 
  +
* SomeEmbeddedLibrary.lua loads third, and is in a subfolder called libs
Both the TagName and tagValue are trimmed: excess whitespace does not prevent the tags from being recognized. Below is a list of tag names and descriptions of how their values are used:
 
; Interface : Specifies which client interface version the addon was made for. If the value of this tag does not match the client interface version, the addon is loaded only if the "Load out of date addons" option is enabled. There are a number of ways [[Getting the current interface number|to determine the current interface version]].<pre>## Interface: 40000</pre>
 
; Title : The value of this tag is displayed in the AddOns list. Localized versions can be included by appending a hyphen followed by the client locale name; the client automatically chooses a localized version if one is available. The value may also contain [[UI escape sequences]], such as for example colors. <pre>## Title: Waiting for Godot</pre><pre>## Title-frFR: En attendant Godot</pre>
 
; Notes : Addon description that appears when the user hovers over the addon entry in the addons list. Like Title, this tag can be localized by appending a hyphen followed by locale name, and contain [[UI escape sequences]]. <pre>## Notes: "Nothing to be done"</pre>
 
; RequiredDeps, Dependencies, or any word beginning with "Dep" : A comma-separated list of addon (directory) names that must be loaded before this addon can be loaded. <pre> ## Dependencies: someAddOn, someOtherAddOn</pre>
 
; OptionalDeps : A comma-separated list of addon (directory) names that should be loaded before this addon if they ''can'' be loaded. <pre>## OptionalDeps: someAddOn, someOtherAddOn</pre>
 
; LoadOnDemand : If this value of this tag is "1", the addon is not loaded when the user first logs in, but can be loaded by another addon at a later point. This can be used to avoid loading situational addons.<pre>## LoadOnDemand: 1</pre>
 
; LoadWith : A comma-separated list of addon (directory) names that, when loaded, will cause the client to load this LoadOnDemand addon as well. Added in Patch 1.9<pre>## LoadWith: someAddOn, someOtherAddOn</pre>
 
; LoadManagers : A comma-separated list of addon (directory) names; if no addons on this list are loaded, the client will load your addon when the user logs in; if at least one addon on this list is loaded, your addon is treated as LoadOnDemand. Introduced in patch 2.1; an example of a LoadManager is [http://www.wowace.com/addons/addon-loader/ AddonLoader].
 
; SavedVariables : A comma-separated list of variable names in the global environment that will be saved to disk when the client exits, and placed back into the global environment when your addon is loaded; the variables are not available before the {{api|t=e|ADDON_LOADED}} event fires for your addon. See [[Saving variables between game sessions]]. <pre>## SavedVariables: foo, bar</pre>
 
; SavedVariablesPerCharacter : A comma-separated list of variable names in the global environment that will be saved to disk when the client exits, and placed back into the global environment when your addon is loaded for a particular character. Note that PerCharacter saved variables are only loaded for the character for which they were saved.<pre>## SavedVariablesPerCharacter: somePercharVariable</pre>
 
; DefaultState : Determines whether the addon is enabled by default when first installed. If the value of this tag is "disabled", the user must explicitly enable the addon in the addons list before it is loaded.<pre>## DefaultState: enabled</pre>
 
; Secure : If the value of this tag is 1, and the addon is digitally signed by Blizzard, its code is considered secure (as opposed to tainted, which is what all 3rd-party addons are). Introduced in Patch 1.11.
 
; Author : The AddOn author's name
 
; Version: The AddOn version. Some automatic updating tools may prefer that this string begins with a numeric version number.
 
   
  +
Not every file must appear in a .toc list:
== Metadata tags ==
 
  +
* xml files may contain [[XML elements#NonWidgets|<Script file="nameOfAnotherFile.lua" />]] or <Include file="alsoLoadThis.xml"/>
It is possible for addons to query values of any tags with a "X-" prefix. Some possibilities include:
 
  +
* {{api|Texture SetTexture}} and {{api|PlaySoundFile}} can use images and sounds contained within the addon folder and its subfolders
* X-Date
 
  +
* X-Website
 
  +
== Interface version ==
* X-Feedback
 
  +
  +
## Interface: {{API LatestInterface}}
  +
  +
The interface metadata specifies which version of the game client the addon has been made for. This field prevents users from experiencing errors by loading out-of-date addons or mixing Retail and Classic; unless they explicity ignore warnings and choose "Load out of date addons". Omitting this field causes the game to treat the addon as always out of date.
  +
  +
There are a number of ways to get the current interface version:
  +
:; It probably is {{API LatestInterface}} (retail) or {{API LatestInterface|classic}} (classic): But these numbers are [[Template:API LatestInterface|maintained locally]], so they ''might'' be out of date.
  +
:; Use {{api|GetBuildInfo}} : In particular, <code>/dump select(4, GetBuildInfo())</code> should output the correct version to your chat frame.
  +
:; Extract FrameXML and check FrameXML.toc: Launch wow with the <code>-console</code> flag, then at the login screen, activate the console using the `/~ key, and type <code>ExportInterfaceFiles code</code> to extract FrameXML files into World of Warcraft\BlizzardInterfaceCode.
  +
:; Steal it from another AddOn : Recently updated AddOns, which are not listed as "out of date" by the client contain the latest Interface version in their toc tag.
  +
Prior to [[patch 8.2.0]]:
  +
:; View FrameXML.toc online: For instance at [https://github.com/Gethe/wow-ui-source/blob/ea161a9537edcc5f5429640af3c5a1370912c6f5/FrameXML/FrameXML.toc wowcompares].
  +
  +
== Display in the addon list ==
  +
  +
The following metadata change how an addon appears in the addon list.
  +
  +
These tags support localization, which may written by appending a hyphen and the locale code to the tag name, such as <code>Title-enGB</code>. See [[Localization]] for a full list of current locale codes.
  +
  +
Coloring is possible via [[UI escape sequences]] <code>|c########</code>.
  +
  +
; Title : String - The name to display on the AddOns list (default: name of the addon's folder).
  +
## Title: Waiting for Godot
  +
## Title-frFR: En attendant Godot
  +
; Notes : String - The description displayed when the user hovers over the addon entry in the AddOns list.
  +
## Notes: This word is |cFFFF0000<span style="color:red">red<span>!
  +
  +
== Loading conditions ==
  +
  +
The following metadata changes when and how an addon loads:
  +
 
; RequiredDeps, Dependencies, or any word beginning with "Dep" : String - A comma-separated list of addon (directory) names that must be loaded before this addon can be loaded. <pre> ## Dependencies: someAddOn, someOtherAddOn</pre>
 
; OptionalDeps : String - A comma-separated list of addon (directory) names that should be loaded before this addon if they ''can'' be loaded. <pre>## OptionalDeps: someAddOn, someOtherAddOn</pre>
 
; LoadOnDemand : Number - If this value of this tag is "1", the addon is not loaded when the user first logs in, but can be loaded by another addon at a later point. This can be used to avoid loading situational addons.<pre>## LoadOnDemand: 1</pre>
 
; LoadWith : String - A comma-separated list of addon (directory) names that, when loaded, will cause the client to load this LoadOnDemand addon as well. <pre>## LoadWith: someAddOn, someOtherAddOn</pre>
 
; LoadManagers : String - A comma-separated list of addon (directory) names; if no addons on this list are loaded, the client will load your addon when the user logs in; if at least one addon on this list is loaded, your addon is treated as LoadOnDemand. An example of a LoadManager is [http://www.wowace.com/addons/addon-loader/ AddonLoader].
 
; SavedVariables : String - A comma-separated list of variable names in the global environment that will be saved to disk when the client exits, and placed back into the global environment when your addon is loaded; the variables are not available before the {{api|t=e|ADDON_LOADED}} event fires for your addon. See [[Saving variables between game sessions]]. <pre>## SavedVariables: foo, bar</pre>
 
; SavedVariablesPerCharacter : String - A comma-separated list of variable names in the global environment that will be saved to disk when the client exits, and placed back into the global environment when your addon is loaded for a particular character. Note that PerCharacter saved variables are only loaded for the character for which they were saved.<pre>## SavedVariablesPerCharacter: somePercharVariable</pre>
 
; DefaultState : String - Determines whether the addon is enabled by default when first installed. If the value of this tag is "disabled", the user must explicitly enable the addon in the addons list before it is loaded.<pre>## DefaultState: enabled</pre>
  +
  +
== Informational ==
  +
The following metadata do not change how an addon behaves, but may be accessed using {{api|GetAddOnMetadata}}:
  +
 
; Author : String - The AddOn author's name, displayed
 
; Version: String - The AddOn version. Some automatic updating tools may prefer that this string begins with a numeric version number.
  +
; X-_____: String - Any custom metadata prefixed by "X-", such as "X-Date", "X-Website" or "X-Feedback"
  +
  +
== Restricted ==
 
; Secure : Number - If the value of this tag is 1 and the addon is digitally signed by Blizzard, its code is considered [[Secure Execution and Tainting|secure]].
   
 
== Notes ==
 
== Notes ==
 
* WoW reads up to the first 1024 characters of each line only. Additional characters are ignored and do not cause an error.
 
* WoW reads up to the first 1024 characters of each line only. Additional characters are ignored and do not cause an error.
  +
* The list of files may be edited while the game is open (taking effect after <code>/reload</code>), but changing metadata has no effect and any files must have already been inside the AddOns folder
* The .toc files are read only when the client initially starts up. Any changes made to the .toc file will be ignored by a running client until the client is restarted (more specifically, content read from .toc files is not refreshed when you reload the user interface or log out / log in. Although some changes will be picked up if you log out to the character selection screen and back in).
 
  +
* Prefixing a line with one # will mark it as a comment, meaning that it will not be read. For example:
 
  +
== Patch changes ==
# This is a comment
 
  +
* {{Patch 9.0.1|note=[[MACRO reload|/reload]] recognizes changes to TOC metadata and entirely new files.}}
  +
* {{Patch 4.0.1|note=[[MACRO reload|/reload]] recognizes changes to the file order.}}
  +
* {{Patch 2.1.0|note=Added LoadManagers metadata}}
  +
* {{Patch 1.11.0|note=Added Secure metadata}}
  +
* {{Patch 1.9.0|note=Added LoadWidth metadata}}
   
 
== See also ==
 
== See also ==
Line 48: Line 96:
 
* {{api|GetAddOnMetadata}} returns information listed in a specified .toc tag.
 
* {{api|GetAddOnMetadata}} returns information listed in a specified .toc tag.
 
* {{api|GetBuildInfo}} returns the client's interface version
 
* {{api|GetBuildInfo}} returns the client's interface version
* {{api|GetLocale}} returns the client's locale.
 

Revision as of 22:36, 9 April 2021

.toc (Table of Contents) files contain information about a particular addon (such as its name, description, saved variables, etc), as well as instructions on how the addon should be loaded by the client (for example, the order in which lua and xml files should be loaded). The file must be present, and have the same name (plus extension) as its parent folder for the addon to be recognized by the client.

Basic rules

The game client searches each subfolder of ...\Interface\AddOns\ (only one level deep) for .toc files having the same name as the subfolder. This .toc file has instructions of the following format:

  • Metadata printed as ## TagName : tagValue, where whitespace is trimmed (except at the start of a line)
  • Comments printed as # this is a comment ignored by the client
  • A list of files to be loaded as myFile.xml or subfolder/anotherFile.lua
## Interface: 100206
## Title: Waiting for Godot
## Notes: Nothing to be done.
## Version: 4.2
Vladimir.xml
Estragon.lua
libs/SomeEmbeddedLibrary.lua

# This is a comment

File load order

The .toc file provides an ordered list of files to be loaded by the client. In the earlier example:

  • Vladimir.xml loads first, and is in the same folder as the .toc file
  • Estragon.lua loads second, and is in the same folder as the .toc file
  • SomeEmbeddedLibrary.lua loads third, and is in a subfolder called libs

Not every file must appear in a .toc list:

  • xml files may contain <Script file="nameOfAnotherFile.lua" /> or <Include file="alsoLoadThis.xml"/>
  • Texture SetTexture and PlaySoundFile can use images and sounds contained within the addon folder and its subfolders

Interface version

## Interface: 100206

The interface metadata specifies which version of the game client the addon has been made for. This field prevents users from experiencing errors by loading out-of-date addons or mixing Retail and Classic; unless they explicity ignore warnings and choose "Load out of date addons". Omitting this field causes the game to treat the addon as always out of date.

There are a number of ways to get the current interface version:

It probably is 100206 (retail) or 11501 (classic)
But these numbers are maintained locally, so they might be out of date.
Use GetBuildInfo
In particular, /dump select(4, GetBuildInfo()) should output the correct version to your chat frame.
Extract FrameXML and check FrameXML.toc
Launch wow with the -console flag, then at the login screen, activate the console using the `/~ key, and type ExportInterfaceFiles code to extract FrameXML files into World of Warcraft\BlizzardInterfaceCode.
Steal it from another AddOn
Recently updated AddOns, which are not listed as "out of date" by the client contain the latest Interface version in their toc tag.

Prior to patch 8.2.0:

View FrameXML.toc online
For instance at wowcompares.

Display in the addon list

The following metadata change how an addon appears in the addon list.

These tags support localization, which may written by appending a hyphen and the locale code to the tag name, such as Title-enGB. See Localization for a full list of current locale codes.

Coloring is possible via UI escape sequences |c########.

Title
String - The name to display on the AddOns list (default: name of the addon's folder).
## Title: Waiting for Godot
## Title-frFR: En attendant Godot
Notes
String - The description displayed when the user hovers over the addon entry in the AddOns list.
## Notes: This word is |cFFFF0000red!

Loading conditions

The following metadata changes when and how an addon loads:

RequiredDeps, Dependencies, or any word beginning with "Dep"
String - A comma-separated list of addon (directory) names that must be loaded before this addon can be loaded.
 ## Dependencies: someAddOn, someOtherAddOn
OptionalDeps
String - A comma-separated list of addon (directory) names that should be loaded before this addon if they can be loaded.
## OptionalDeps: someAddOn, someOtherAddOn
LoadOnDemand
Number - If this value of this tag is "1", the addon is not loaded when the user first logs in, but can be loaded by another addon at a later point. This can be used to avoid loading situational addons.
## LoadOnDemand: 1
LoadWith
String - A comma-separated list of addon (directory) names that, when loaded, will cause the client to load this LoadOnDemand addon as well.
## LoadWith: someAddOn, someOtherAddOn
LoadManagers
String - A comma-separated list of addon (directory) names; if no addons on this list are loaded, the client will load your addon when the user logs in; if at least one addon on this list is loaded, your addon is treated as LoadOnDemand. An example of a LoadManager is AddonLoader.
SavedVariables
String - A comma-separated list of variable names in the global environment that will be saved to disk when the client exits, and placed back into the global environment when your addon is loaded; the variables are not available before the ADDON_LOADED event fires for your addon. See Saving variables between game sessions.
## SavedVariables: foo, bar
SavedVariablesPerCharacter
String - A comma-separated list of variable names in the global environment that will be saved to disk when the client exits, and placed back into the global environment when your addon is loaded for a particular character. Note that PerCharacter saved variables are only loaded for the character for which they were saved.
## SavedVariablesPerCharacter: somePercharVariable
DefaultState
String - Determines whether the addon is enabled by default when first installed. If the value of this tag is "disabled", the user must explicitly enable the addon in the addons list before it is loaded.
## DefaultState: enabled

Informational

The following metadata do not change how an addon behaves, but may be accessed using GetAddOnMetadata:

Author
String - The AddOn author's name, displayed
Version
String - The AddOn version. Some automatic updating tools may prefer that this string begins with a numeric version number.
X-_____
String - Any custom metadata prefixed by "X-", such as "X-Date", "X-Website" or "X-Feedback"

Restricted

Secure
Number - If the value of this tag is 1 and the addon is digitally signed by Blizzard, its code is considered secure.

Notes

  • WoW reads up to the first 1024 characters of each line only. Additional characters are ignored and do not cause an error.
  • The list of files may be edited while the game is open (taking effect after /reload), but changing metadata has no effect and any files must have already been inside the AddOns folder

Patch changes

See also