Lua is a small, efficient, interpreted scripting language that can be easily embedded into any language, and many applications and games use LUA as their embedded scripting language for configuration and scalability. This includes World of Warcraft, the gate of Lourdes, Angry Birds, VOCALOID3, sun god Three Kingdoms kill.
Download and compile
Download Connection: http://www.lua.org/download.html, click the download button to download the LUA source code.
Extracted after the source code is not directly used, we also need to manually compile to use.
Compile under Window
Basically we need to install vs to compile.
Compiling Lua.exe
The program is the LUA interpreter.
- Create a new VC + + Console application, the project name is LUA;
- Remove the pre-compiled header check;
- Copy all the files in the extracted SRC folder to the project folder, you need to note that luac.c do not copy, and lua.c to keep;
- Click "Show All Files" button in "Explorer", you can see all the source files copied;
- Select all the source files, right click "Include in Project", all the source files can be included in the project;
- Lua.exe files can be obtained by running the project;
Compiling Luac.exe
The program is the LUA compiler.
The steps are consistent with the above, except that the LUAC.C is preserved and the LUA.C is removed.
Compiling a LUA static or dynamic library
The steps are consistent with the above, except that both LUA.C and LUAC.C are removed, and when the project is created, the corresponding type is selected, whether it is a DLL or a static library.
MacOS under Compile
It's very handy with windows, and you don't need to install anything, just go through the terminal and type "make MacOS" command.
Development tools
工欲善其事 its prerequisite, we need a handy IDE to edit LUA code, the following two I would like to recommend the IDE to everyone.
LDT
: http://www.eclipse.org/koneki/ldt/
The LDT itself has integrated the LUA compiler and interpreter, we can directly extract after the direct use without making any changes, very convenient.
Sublime
Sublime is my personal favorite editor, which natively supports the syntax coloring of LUA scripts, and we have a simple configuration that allows them to run LUA code, but it is important to note that this function is only to run LUA scripts, and the results are only equivalent to Lua [Filename.lua] , unable to enter text control, colleagues can not set breakpoints for debugging, if you need these functions, please use the above LDT.
To configure Windows as an example:
- First, we find the path of the lua.exe we started to generate.
- Click "Tools", "Build System", "New build System";
- Fill in the following script:
{ "cmd": ["E:\\study\\c++\\lua\\debug\\lua.exe", "$file"], "File_regex": "^ (?: Lua:)? [ \ t] (...):( [0-9]*):? ([0-9]*) ", " selector ":" Source.lua "}
- Save as Lua;
- Our LUA script can then be run directly by clicking on "Tools", "Build".
Lua Learning Note (i): Building a development environment