標籤:
測試Lua環境是否已經安裝:
adeMacBook-Pro:perl_dev apple$ lua-bash: lua: command not found
View Code
如果沒有的話就到lua官方去下載:(網址:http://www.lua.org/download.html)
參考說明:
make的時候 是指定macosx
adeMacBook-Pro:lua_soft apple$ curl -R -O http://www.lua.org/ftp/lua-5.3.0.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- 0:00:04 --:--:-- 0 5 271k 5 15508 0 0 2238 0 0:02:04 0:00:06 0:01:58 3533100 271k 100 271k 0 0 31308 0 0:00:08 0:00:08 --:--:-- 83547
View Code
curl -R -O http://www.lua.org/ftp/lua-5.3.0.tar.gztar zxf lua-5.3.0.tar.gzcd lua-5.3.0make linux test
測試安裝成功與否和版本號碼是否正確
adeMacBook-Pro:lua-5.3.0 apple$ luaLua 5.3.0 Copyright (C) 1994-2015 Lua.org, PUC-Rio
查看Lua的目錄
adeMacBook-Pro:lua-5.3.0 apple$ which lua/usr/local/bin/lua
配置SubmlineText中Lua環境Tool->Build System -> New Build System中添加代
{ "cmd": ["/usr/local/bin/lua", "$file"], "file_regex": "^(...*?):([0-9]*):?([0-9]*)", "selector": "source.lua" }
View Code
然後儲存為Lua.sublime-build.
第四步:建立一個HelloWorld.lua檔案,隨便輸入語句,然後選擇Lua為build System,按一下command+b
附一段小程式:
adeMacBook-Pro:lua_dev apple$ vim hel.lua
-- Fibonacci sequence with coroutinesfunction fibo() a, b = 0, 1 while true do coroutine.yield(a) a, b = b, a + b endendco = coroutine.create(fibo)n = arg[1] or 20for i = 0, n do print(i,coroutine.resume(co))end
View Code
adeMacBook-Pro:lua_dev apple$ lua hel.lua0 true 01 true 12 true 13 true 24 true 35 true 56 true 87 true 138 true 219 true 3410 true 5511 true 8912 true 14413 true 23314 true 37715 true 61016 true 98717 true 159718 true 258419 true 418120 true 6765
View Code
Mac OS X 上的安裝Lua開發環境