Getting Started with Lua for Windows 01

Source: Internet
Author: User
Tags sublime text

Because of the urgency of the project, I didn't have time to study the basics of Lua and went straight to the gun. In the process of writing, it was discovered that the programming language was so beautiful for the first time.

With the full installation of the lua+for+windows+5.1.4-45 version, a example browsing was finally jumped out.  This is a good opportunity to get started, and quickly open another lua.cmd in accordance with the gourd painting scoop to write it again. There are some places that are different from C, which are summarized as follows:

After 1.if, then end will be finished, if then ElseIf then else end; function f end; F=funciton End

2. When declaring a variable, adding local is the local variable, otherwise it is a global variable

3. Footnotes starting from 1, c starting from 0; ~= equivalent to! =

4. You can assign a value together with the number of multiple variables and multivariate types. such as A,b,c = 1,2,3,4 extra value is meaningless, a,b,c=1,2 extra variable is nil

5. The ability to string processing is extremely powerful. Letters are case sensitive.   String connection with: , take the string length with #.

6.b= (a==1) and "one" or "not one" are equivalent to b= (a=1)? 1:0;

7.print will be wrapped, io.write will not.

8.

The command line interface always feels less friendly and intelligent if you learn it by yourself. So I think with the most powerful affinity sublime text to learn to develop and compile. Although the sublime comes with a support for LUA highlighting, there is no build system.  So CTRL shift P is required to install the package, and this process requires networking. Then create a new build system under tools to change the source code to:

1 {2     "cmd": ["Lua","$file"],3     "File_regex":"^ (?: Lua:)? [ \ t] (...):( [0-9]*):? ([0-9]*)",4     "selector":"Source.lua"5}

After the change is saved in the C:\Users\Administrator\AppData\Roaming\Sublime Text 3\packages\user directory. Then, in the process of compiling LUA, you can select Lua in the build of tools, so that you can write LUA programs at will, and then press Ctrl+b to compile and view the results. Such as:

Getting Started with Lua for Windows 01

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.