您的位置:首页 > 编程语言 > Lua

lua (一) : mac终端下使用 brew安装lua

2015-06-18 22:09 543 查看
*mac下的安装

brew工具套装网址:brew.sh

1.安装brew:终端下执行一下命令

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"[/code] 
2.执行命令 :
brew install lua
安装lua

3.成功后,执行命令 :
lua
进入lua脚本环境

4.经典开始

> print("hello world")
hello world


> var = "hello"
> print(var)
hello


> print ("x" .. "y")
xy


5.执行lua脚本

创建文本文件hello.lua

内容为:

print("hello lua!")
name = io.read()
print("hello " .. name)


终端下执行文件目录下执行

$ lua helloLus.lua
hello lua!
lee
hello lee


如果无法执行,对文本添加执行权限,执行:

$ chmod +x hello.lua
//查看文件权限
$ ls -l
-rwxr-xr-x  1 binlinghu  staff  20  6 18 21:36 hello.lua


然后再执行:

$ lua helloLus.lua
hello lua!
lee
hello lee
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: