Lua is very easy to learn, and we can create the first Lua program! Lua provides an interactive programming mode. We can enter the program on the command line and see the effect immediately. Lua interactive programming mode can be realized by command On the command line, enter the following command: Then we press the enter key and the output is as follows: We can save the Lua program code to a 4.3.1. The first Lua program #
Interactive programming #
lua
-i
or
lua
to enable:$ lua -i
$ Lua 5.3.0 Copyright (C) 1994-2015 Lua.org, PUC-Rio
>
> print("Hello World!")
> print("Hello World!")
Hello World!
>
Script programming #
lua
at the end of the file, and execute, this pattern is called scripted programming, such as we store the following code in a file named
hello.lua
in the script file: