World of WarCarft plug-in configuration

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
2
3
4
5
6
7
8
9
10
11
12
13
14
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; 
the Title: plug-in name, the selected character will be displayed in the game list plugin;
title - zhCN: plug-in Chinese display, if you want to be displayed in other languages, modify - back on it; the following is true Notes;
Notes: plug-in list, mouse over the message displayed when the plug-in name;
RequiredDeps, the Dependencies, or any to "Dep" beginning of the string: that other plug-ins our current plug-in must be loaded;
OptionalDeps: with the above controls, plug-in here is optional;
LoadOnDemand: a value of 1 , it indicates that the plug will not be in the game start loading, but only loaded when needed;
LoadWith: if the value is above 1 , the plug-ins described in this section will be loaded together with this plug-in;
LoadManagers: plug-in described in this clause, if not present, this plug will automatically load; if there is a presence, is press LoadOnDemand 1 processing;
SavedVariables: number comma Segmentation variable name, these variables will be saved on the hard disk can be read until the next load;
SavedVariablesPerCharacter: above the label is the same effect, but the label is only used to hold different roles of different configurations;
DefaultState: This plug-in is enabled by default state is Disabled / Enabled;
Author: Author Name
Version: the version number of the plug

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.luadocument 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
2
3
4
5
6
7
8
9
10
11
12
<Bindings> 
<Binding name="CUBE_CODE" header="CUBE">
if IGAS.UIParent.Cube_Main then
IGAS.UIParent.Cube_Main.Visible = not IGAS.UIParent.Cube_Main.Visible
end
</Binding>
<Binding name="CUBE_DEBUG">
if IGAS.UIParent.Cube_Debug then
IGAS.UIParent.Cube_Debug.Visible = not IGAS.UIParent.Cube_Debug.Visible
end
</Binding>
</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
2
3
4
-- Binding Text 
_G.BINDING_HEADER_CUBE = L["Cube"]
_G.BINDING_NAME_CUBE_CODE = L["Simple Dev Tool"]
_G.BINDING_NAME_CUBE_DEBUG = L["Simple Debug Tool"]

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
2
3
4
5
6
7
8
<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"> 

<Script file = "IGAS_Toolkit.lua"/>


<Include file = "ModulesAutoRepairAutoRepair.xml"/>
<Include file = "ModulesAutoSellAutoSell.xml"/>
</Ui>

Wherein < /> This tag is xml document, by the type of label will be < identification name of the latter, as Scriptthe label for loading lua document, Includefor 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
2
3
4
5
6
7
8
-- Load DHAddon 
local DHAddon = {}

f = loadfile("devil.lua")
( "DHAddon", DHAddon )

f = loadfile("hunter.lua")
( "DHAddon", 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
2
3
4
5
local addonName, addon = ... 

print(addonName .. " is loaded.")

addon.DHAddon = 123

hunter.lua:

1
2
3
local addonName, addon = ... 

print( "DHAddon is " .. addon.DHAddon )

不出意外的话,运行结果会是:

DHAddon is loaded.
DHAddon is 123

另外上面的两个lua文档也可以下面这么写,其中有好多lua的内容,暂不解释原因,贴在这里之后了解到了再来回顾:

1
2
3
4
5
6
7
8

-- 并且在addon环境中可以访问_G的任意变量,访问的变量值也将存储到addon中,便于下次直接访问
-- 下面的代码定义的全局变量都将保存在addon表中,而非_G
setfenv(1, setmetatable(select(2, ...), { __index = function(self, key) local v = _G[key]; rawset(self, key, v); return v end }))

function testA()
print("devil case A")
end
1
2
3
4
5
-- 插件的其他lua文档仅需要设置运行环境 
setfenv(1, select(2, ...))

- Devil .lua defined functions can be called directly
testA ()

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 ...

Guess you like

Origin www.cnblogs.com/liuzhongrong/p/12000172.html