Today plug-in is to talk about wow what the hell?
World of Warcraft plug-in is the third open interfaces, a friend will ask, what is the third party? The software industry is a term, simply put, is the game which will allow us to customize your own DIY part, say functional dialog interface, there are some data and the like.
wow plug-in save all of Warcraft / Interface World / AddOns directory, there will be some snow comes with features plug-ins in this directory, they are based on Blizzard_ beginning of our own plug-ins can be named anything different plug-in placed in separate documents folder (do we plug in the process, it is strongly recommended to use the English name, to avoid causing problems because the Chinese plug-ins can not be identified) below. http://www.townlong-yak.com/framexml/ this web site can be downloaded Blizzard comes with plug-ins.
Talk about plug-in structure, open plugins directory, you will find that there will be roughly three types of documents, namely toc documents, xml documents and lua files.
toc document
This document is a necessary document, its name and the name of your plug-in documentation folder of the same name, but with a suffix toc, if different name, then open the World of Warcraft client will not recognize your plug-ins;
note! ! ! Beginning of each line of this document can not have spaces per line for only one explanation.
Toc open the document using the text tool, description, three types:
At the beginning of the ## data
Used to describe the plug, generally have plug-in name, author name, and other functional description; it is the basic format
1 |
The label name can easily write, but there are some wow own label name we explain yourself:
1 |
Interface: version of the game available in the plug-wow mark, when the value is lower than the current version of the game less than the plugin will not be loaded; |
In addition, you can define your own label, above the most important thing is the first two, try not to mistake;
This plug-in to load code documentation
Code classes listed in the document to load, only supports lua and xml formats, document where the need to give the full path to the document root directory of the current directory, that is, if there is a plugin directory under your myaddon.lua
document you need to add:
1 |
myaddon .lua |
And if there is a sub-folder under your document plug-in directory myAddOn , while one in this directory myaddon2.lua
, then you need to add:
1 |
MyAddon / myaddon2. moon |
At the beginning of the document #
These are the comment text, you can easily add toc mainly used as a plug-in to record themselves, these plug-ins will not be loaded;
XML documents
xml document is mainly used for production of plug-in interfaces, and the event binding, binding popular talk is an event you do certain actions (press a button and the like) in the event the game will appear on plug-ins, these events are a way to lua appeared in the form of a document, you can put your own thing written in this method, if you learn some programming, you should know what we say here is to lua function;
In your root directory of the plug-in will be called Bindings.xml document, the document will be automatically read the game client, toc not have to write in the document;
We look at an example of the document:
1 |
<Bindings> |
We do not control these being the first meaning of the code, only need to know this document sets binding interface elements and the game event, and the event is done by Lua binding document; bindings.xml document binding and insert a large column World of constituting WarCarft plug- lua file names with the same name, and the event will also be an element on the interface with the document described bound together:
1 |
-- Binding Text |
We now first do not control how they are linked, in particular after the code we write process will slowly mentioned, now just a little understanding, xml will define our interface, and the binding interface elements and events can also be set and the event will be referred to binding lua document processing;
We can also load other lua and xml documents, the following example:
1 |
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/..FrameXMLUI.xsd"> |
Wherein < /> This tag is xml document, by the type of label will be < identification name of the latter, as Script
the label for loading lua document, Include
for loading other xml document;
lua document
Lua is the main language of logic wow plug, plug-ins do before you need to familiarize yourself with the lua syntax, not anti interested to know some of the learning of the search suggestions at peace, to find some introductory information, in my Guestbook public number, we can learn to discuss the next; here we give some brief clips, aims to look at its role;
Suppose we now make a plug-in, called DHAddon (think DH is not a demon hunter abbreviation Yeah Devil Hunter??), There are two plug-Lua documents devil.lua hunter.lua;
wow load them manner similar to the following code:
1 |
-- Load DHAddon |
loadfile is loading the document, document name is represented by a string (lua syntax "" string that represents); loads the results are stored in the f;
devil.lua:
1 |
local addonName, addon = ... |
hunter.lua:
1 |
local addonName, addon = ... |
不出意外的话,运行结果会是:
DHAddon is loaded.
DHAddon is 123
另外上面的两个lua文档也可以下面这么写,其中有好多lua的内容,暂不解释原因,贴在这里之后了解到了再来回顾:
1 |
|
1 |
-- 插件的其他lua文档仅需要设置运行环境 |
Constitute a plug-in so much, a lot of things do not really understand, slowly understanding enough; Benpian on this, and the public who are interested can follow number "Azeroth daily," we come together to explore ...