So, today we are going to learn our first Lua Program. Yes! You have guessed it correctly. It’s the “Hello World” program.
We have already installed the required Interpreter for Compiling and Executing Lua code on out machine. (Refer: Programming in Lua)
- Open Visual Studio Code and create a new file.
- Lua uses the
print(...)to output text to the console. So, we are gonna write
print("Hello World")This will output a string “Hello World” onto the console.
- Save the program with the filename extension as
.luato your desired folder path.
- Open a command window in the folder path and type
lua <filename.lua>and hit return to compile and execute the program.
- You have successfully written the first Lua Program.
You will see the following result in your command windows.