LUA Environment and Setup

本文详细介绍了如何在MAC环境下安装配置Lua环境,并通过简单的Hello World示例进行验证。此外,还介绍了如何使用IntelliJ IDEA编辑并运行Lua脚本,提供了递归实现阶乘的示例代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

LUA Environment and Setup

1. Install the environment on MAC
>wget http://www.lua.org/ftp/lua-5.2.3.tar.gz
>tar zxf lua-5.2.3.tar.gz
>cd lua-5.2.3
>make macosx test

>sudo make macosx install

Verify the installation
>lua -v
Lua 5.2.3 Copyright (C) 1994-2013 Lua.org, PUC-Rio

First Hello World
>vi hello.lua
print("hello")

>lua hello.lua
hello

Just use Intellij and install the plugin
[Preferences] ——> [Plugins] ———> [Browse Repositories] ———> Search for ‘lua for’ and I will get Lua language integration for IntelliJ

Then I can edit the Lua script in my intelliJ and run them using my command line.

If I want to run the script inside IntelliJ, I will click on the ‘edit configuration’ and change the ‘Lua interperter’ and ‘Working directory’ there.

Lua interperter —> /usr/local/bin/lua
Working directory —> /Users/carl/work/easy/easylua/src/main/lua

Go over my old blog and tried some examples there. All the examples are in the project easylua.

function fact(n)
if n== 0 then
return 1
else
return n*fact(n-1)
end
end

print("enter a number:")
a = io.read("*number")
print(fact(a))

2. Learn from the TutorialDirectory
Lua Types Tutorial


References:
http://sillycat.iteye.com/blog/1460991
http://sillycat.iteye.com/blog/1460997

Official Website
http://www.lua.org/download.html
http://www.lua.org/manual/5.2/


http://lua-users.org/wiki/LuaTutorial
http://lua-users.org/wiki/LuaDirectory
http://lua-users.org/wiki/TutorialDirectory

http://www.cnblogs.com/stephen-liu74/archive/2012/07/30/2487201.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值