国产探花免费观看_亚洲丰满少妇自慰呻吟_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
 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 年辖:市辖区| 德保县| 筠连县| 德州市| 新巴尔虎右旗| 江源县| 大兴区| 滕州市| 玉树县| 开阳县| 托克托县| 永州市| 杭锦旗| 远安县| 华宁县| 达州市| 启东市| 招远市| 岐山县| 罗田县| 萝北县| 霸州市| 阆中市| 繁昌县| 维西| 莆田市| 沙雅县| 独山县| 兴和县| 清水河县| 宁安市| 保亭| 健康| 泽州县| 花莲县| 峨山| 阳城县| 左云县| 益阳市| 岳普湖县| 抚远县|