--------------------"unit"----------------------
"partyN"
The Nth party member excluding the player (1,2,3 or 4).
"partypetN"
The pet of the Nth party member (N is 1,2,3, or 4) (Added in 1.5.0).
"raidN"
The raid member with raidIndex N (1,2,3,...,40).
"raidpetN"
The pet of the raid member with raidIndex N (1,2,3,...,40) (Added in 1.5.0)
--------------------"unit"----------------------
UnitAura("unit", index or "buffName" [,filter]) - Returns information about a buff/debuff of a certain unit.
UnitBuff("unit", index or "buffName" [,castable]) - Retrieves info about a buff of a certain unit.
UnitDebuff("unit", index or "buffName" [,removable]) - Retrieves info about a debuff of a certain unit.
GetComboPoints() - Get the current number of combo points.
UnitHealth("unit") - Returns the current health, in points, of the specified unit.
UnitHealthMax("unit") - Returns the maximum health, in points, of the specified unit.
UnitPower("unit"[,type]) - Returns current power of the specified unit (Replaces UnitMana() as of WoW 3.0.2)
UnitPowerMax("unit"[,type]) - Returns max power of the specified unit (Replaces UnitManaMax() as of WoW 3.0.2)
UnitMana("unit") - Returns the current mana (or energy,rage,etc), in points, of the specified unit. (Replaced by UnitPower() as of WoW 3.0.2)
UnitManaMax("unit") - Returns the maximum mana (or energy,rage,etc), in points, of the specified unit. (Replaced by UnitPowerMax() as of WoW 3.0.2)
GetNumPartyMembers() - Returns the number of other players in your party (0-4).
GetNumRaidMembers() - Returns the number of players in your raid group.
GetSpellCooldown(spellName | spellID, "bookType") - Retrieves data on the cooldown of a specific spell.
PROTECTED CastSpellByName("name"[, onSelf]) - Cast the specified spell by display name. As of patch 2.0, this function has been restricted to Blizzard signed UI mods. Note: You can still use this function to open Craft windows and activate Lock Picking.
IsSpellInRange("spellName", [unit]) - Is nil for no valid target, 0 for out of range, 1 for in range.
PROTECTED TargetUnit("unit") - Selects the specified unit as the current target.
HasFullControl()
HasSoulstone()
IsFalling() - Returns 1 if your character is currently plummeting to their doom.
IsFlying() - Returns 1 if flying, otherwise nil.
IsFlyableArea() - Returns 1 if it is possible to fly here, nil otherwise.
IsIndoors() - Returns 1 if you are indoors, otherwise nil. Returns nil for indoor areas where you can still mount.
IsMounted() - Returns 1 if mounted, otherwise nil
IsOutdoors() - Returns 1 if you are outdoors, otherwise nil. Returns 1 for indoor areas where you can still mount.
IsOutOfBounds() - Returns 1 if you fell off the map.
IsResting() - Returns 1 if your character is currently resting.
IsStealthed() - Returns 1 if stealthed or shadowmeld, otherwise nil
IsSwimming() - Returns 1 if your character is currently swimming.
猛虎之怒+60 斜掠(buff)
if 怒氣<40 then
if 冷卻(猛虎之怒) then
end
CastSpellByName("name"[, onSelf])猛虎之怒
else
斜掠
end
-------------------------
if 連擊點數<>5 then
打擊
else
終結技(目標血量 ) dot/kill
end
val 最小生命比例=100%
int 成員id
迴圈團隊成員
{
if(沒有buff1)
{
if(成員生命<最小生命比例)
{
成員名稱 = 該成員名稱
}
}
}
為"成員名稱"上buff1
冪^
>print(13^2)169
模數%
>print(8%3)1
相等==
不等於~=
您可以用“==”運算子來測試一個值是否和nil等價
and、break、do、else、elseif、for、function、if、in、local、nil、not、or、repeat、return、then、true、until和while
foo=14
> x="Hello"
> y="艾澤拉斯"
> print(x..y)
----------------------
> x=tonumber("1234")
if <布林運算式> then
--語句塊
end
if <布林運算式> then
--語句塊1
elseif <布林運算式> then
--語句塊2
elseif <布林運算式> then
--語句塊3
else
--語句塊4
end
while <布林運算式> do
--迴圈體
end
repeat
----迴圈體
until <布林運算式>
for 變數名=初始值,結束值,步長 do
----迴圈體
end
alice={}
> print(alice["name"])
alice[1]="測試資料"
alice[1]=nil
擷取數組的長度
> tbl={"a","b","c"}
> print(#tbl)
3
table.insert()的文法是:
table.insert(數組,[下標,]值)
參數的意義如下:
數組——將被增加元素的數組
下標——增加的元素所在的位置
值 ——這個元素的值
值=table.remove(數組[,下標])
table.sort()
string.sub()
WoW中的多個傳回值
b,c,d=convertHexToRGB("FFFFFF")
> tbl={"蘋果","香蕉","梨"}
> for index,value in ipairs(tbl) do
>> print(index,value)
>> end
1 蘋果
2 香蕉
3 梨
> tbl={
>> "蘋果",
>> "香蕉",
>> "梨",
>> width=100,
>> height=100,
>> }
> for key,value in pairs(tbl) do
>> print(key,value)
>> end
1 蘋果
2 香蕉
3 梨
height 100
width 100
strsplit(sep,str)
> print(strsplit(":","foo:bar:blah"))
foo bar blah、
5.18 建立比較函數
如果我們直接使用 table.sort()函數,它會報錯,因為它不知道應該怎麼對guid裡的三個對象進行排序:
> table.sort(guid)
attempt to compare two table values
stack traceback:
[C]: in function 'sort'
stdin:1: in main chunk
[C]: ?
所以,就需要我們來指究竟如何進行排序,也就是寫一個比較函數,這個函數有兩個參數,這兩個參數就類似於我們表中的任意兩個對象,我們在這個函數中來指明如何判斷對象的大小,那麼 table.sort()就能知道如何對錶進行排序:
> sortLevel=function(a,b)
>> return a.level<b.level
>> end
我們這裡隨意的指定了按對象的等級進行排序,a和b就是guid表中的任意兩個對象,我們在sortLevel中對它們的level屬性進行了比較,並返回了它們的比較結果,tabl.sort()就可以利用這個比較結果來完成排序,只要象下面這樣寫:
> table.sort(guid,sortLevel)
然後再次用for迴圈輸出:
> for key,value in pairs(guid) do
>> print(key,value.name)
>> end
1 真默然
2 默然的兒子
3 默然的老婆
我們看到,已經表中的對象已經改變了順序。
類型 描述
數字(number)
所有的數字(包括十六進位數和那些使用科學計數法的)都屬於這一類。
字串(string)
一個字元序列
布爾值(boolean)
true和false
函數(function)
函數是一個可以調用的語句集合,第3章會講到。
表(table)
表是傳統的雜湊表和數組的混合類型
線程(thread)
線程類型的值是一個可用於非同步計算的協同程式(輕量有限線程)
使用者資料(userdata)
使用者資料就是類似C語言中的結構體類型