佳木斯湛栽影视文化发展公司

主頁(yè) > 知識(shí)庫(kù) > Lua腳本語(yǔ)言基本語(yǔ)法快速入門教程

Lua腳本語(yǔ)言基本語(yǔ)法快速入門教程

熱門標(biāo)簽:Linux服務(wù)器 呼叫中心市場(chǎng)需求 地方門戶網(wǎng)站 服務(wù)外包 AI電銷 網(wǎng)站排名優(yōu)化 鐵路電話系統(tǒng) 百度競(jìng)價(jià)排名

Lua語(yǔ)法與C語(yǔ)言有些相似也不太一樣,寫(xiě)了語(yǔ)句學(xué)一下 微笑

--begin
a = --[[explain]] "ha";
print(a)

if a == "ha" then
 print("if test passed")
else
 print("if used wrong")
end

b,c=2,3
print(b,c)
b,c=c,b
if b==3 and c==2 then
 print("swap test passed")
 print(b,c)
else
 print("swap error")
end

do
 b = 6
 if b==6 then
 print("code block test passed")
 else
 print("code block test error")
 end
end

do
 d=true;
 local e="haha"
end
if d==true and e==nil then
 print("local test passed")
else
 print("local test error")
end

c = 2^3
if c == 8 then
 print("squert test passed")
else
 print("test error")
end

a = "string will be ".."connected"
print(a)

x = x or a --if not x then x = v end
print(x)


print(type(asdf))

c=3-1.2;
print(c)

d = [[
怎么會(huì)
 怎么會(huì)
 你竟原諒了我?

]]
print(d)

function test (w)
 print("the num is "..w)
 local add=w+1
 return add;
end

b=test(5)
print(add,b)


t={
 100,
 [100] = "I'm the 100th element",
 fsy=
 {
 ['age']=22,
 sex = "male", --如果是字符串,可以去掉引號(hào)和括號(hào)
 },--元素之間必須用,隔開(kāi)
 20, -- 相當(dāng)于t[2]=20
}

print(t[0])
print(t[1])
print(t[100])
print(t.fsy.age)
print(t[2])

g = {
 age = 3,
 add=function (s,n) s.age=s.age+n end
}

g:add(10) --相當(dāng)于g.add(g,10)
print(g.age)

運(yùn)行的結(jié)果如下:

>lua -e "io.stdout:setvbuf 'no'" "hello.lua" 
ha
if test passed
2 3
swap test passed
3 2
code block test passed
local test passed
squert test passed
string will be connected
string will be connected
nil
1.8
怎么會(huì)
 怎么會(huì)
 你竟原諒了我?


the num is 5
nil 6
nil
100
I'm the 100th element
22
20
13
>Exit code: 0


您可能感興趣的文章:
  • Lua腳本語(yǔ)言簡(jiǎn)明入門教程
  • Lua極簡(jiǎn)入門指南(一):基礎(chǔ)知識(shí)篇
  • Lua極簡(jiǎn)入門指南(三): loadfile和錯(cuò)誤處理
  • Lua極簡(jiǎn)入門指南(一):函數(shù)篇
  • Lua極簡(jiǎn)入門指南:全局變量
  • lua腳本語(yǔ)言快速入門教程
  • Lua入門學(xué)習(xí)筆記
  • Lua極簡(jiǎn)入門指南(六):模塊
  • Lua 極簡(jiǎn)入門指南(七):面向?qū)ο缶幊?/li>
  • Lua語(yǔ)言新手簡(jiǎn)單入門教程

標(biāo)簽:仙桃 湘潭 銅川 衡水 崇左 湖南 蘭州 黃山

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Lua腳本語(yǔ)言基本語(yǔ)法快速入門教程》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    沈阳市| 尚志市| 泌阳县| 曲靖市| 大渡口区| 贵溪市| 咸宁市| 太康县| 西宁市| 武陟县| 兴安盟| 涿鹿县| 保康县| 武夷山市| 得荣县| 辽阳县| 宁津县| 民和| 桐乡市| 临邑县| 抚州市| 昌都县| 丹棱县| 卢氏县| 桐乡市| 浙江省| 安达市| 霍林郭勒市| 肥城市| 德庆县| 斗六市| 鹤庆县| 扬中市| 拉孜县| 霍邱县| 恭城| 门头沟区| 岳西县| 嘉祥县| 咸丰县| 胶南市|