国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

Lua腳本語言基本語法快速入門教程

2024-07-21 23:04:58
字體:
來源:轉載
供稿:網友

Lua語法與C語言有些相似也不太一樣,寫了語句學一下 微笑

--begina = --[[explain]] "ha";print(a)if a == "ha" then print("if test passed")else print("if used wrong")endb,c=2,3print(b,c)b,c=c,bif b==3 and c==2 then print("swap test passed") print(b,c)else print("swap error")enddo b = 6 if b==6 then print("code block test passed") else print("code block test error") endenddo d=true; local e="haha"endif d==true and e==nil then print("local test passed")else print("local test error")endc = 2^3if c == 8 then print("squert test passed")else print("test error")enda = "string will be ".."connected"print(a)x = x or a --if not x then x = v endprint(x)print(type(asdf))c=3-1.2;print(c)d = [[怎么會 怎么會 你竟原諒了我?]]print(d)function test (w) print("the num is "..w) local add=w+1 return add;endb=test(5)print(add,b)t={ 100, [100] = "I'm the 100th element", fsy= { ['age']=22, sex = "male", --如果是字符串,可以去掉引號和括號 },--元素之間必須用,隔開 20, -- 相當于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) --相當于g.add(g,10)print(g.age)

運行的結果如下:

>lua -e "io.stdout:setvbuf 'no'" "hello.lua" haif test passed2 3swap test passed3 2code block test passedlocal test passedsquert test passedstring will be connectedstring will be connectednil1.8怎么會 怎么會 你竟原諒了我?the num is 5nil 6nil100I'm the 100th element222013>Exit code: 0
 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 新干县| 城口县| 扬州市| 泾川县| 庆安县| 西和县| 聂荣县| 通河县| 丹巴县| 漳浦县| 长丰县| 京山县| 庆安县| 日照市| 漳平市| 台江县| 临澧县| 定边县| 平顺县| 黎平县| 临汾市| 景德镇市| 万载县| 沾益县| 凤山县| 额敏县| 岱山县| 炎陵县| 新安县| 文成县| 万全县| 兴山县| 湄潭县| 虎林市| 眉山市| 饶平县| 嘉祥县| 寿阳县| 南城县| 昂仁县| 汤阴县|