Introduction to Lua
Lua is a small programming language. It was created in 1993 at PUC-Rio, a university in Brazil. The name means "moon" in Portuguese.
Lua is often used inside other programs. A big program, such as a game, can let its users add their own features by writing Lua scripts. A script is a short program that another program runs. Some well-known places where you will find Lua:
- World of Warcraft add-ons
- Plugins for the Neovim text editor
- Scripts that run inside the Redis database
- Many game engines (Roblox uses a version of Lua called Luau)
Lua has very few rules and only a small number of building blocks. That makes it a good first language: you can learn most of it in one course.
Your first Lua program
print("Hello, Lua!")
Output:
Hello, Lua!
That one line is the whole program. print is a function, a named command that does a job. You give print a value inside the parentheses, and it shows that value on the screen. The quotes tell Lua that the value is text.
A Lua program is a list of statements (instructions). Lua runs them from top to bottom, one after another. You don't need to write any setup code around them.
The code editor in this course runs real Lua 5.4. Every lesson ends with an exercise in it, so you can try each idea right away.
Your first exercise is already written for you. Submit it and see Lua print the greeting.