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
LUA Environment and Setup
猜你喜欢
转载自sillycat.iteye.com/blog/2376002
今日推荐
周排行