What's Next

You have reached the end of the course. Here is what you can now do in Lua:

  • print output, read input, and store values in variables
  • work with numbers, strings, booleans and nil
  • make decisions with if, elseif and the logical operators
  • repeat work with for, while and repeat, and stop early with break
  • write functions with parameters, multiple return values and ..., including recursive functions
  • use functions as values, and write closures
  • use tables as lists and dictionaries, loop over them with ipairs and pairs, and nest them
  • search, change and format text with the string library, and use the math library
  • handle errors with error and pcall
  • build objects with methods, and classes with metatables

That is the core of Lua. Most Lua scripts you will read are built from these parts.

What to learn next

Two topics are good next steps.

Modules help you split a big program into files. A module is a file that returns a table of functions. Another file loads it with require. So a module is just a table again, used as a library.

Coroutines are functions that can pause in the middle and continue later. Games use them for things that happen over time, like a character walking from one place to another.

Where to use Lua

Lua was made to be embedded: a small Lua engine runs inside a bigger program, and that program lets you control it with Lua scripts. So the best way to practice is to pick a program that uses Lua and write something real for it:

  • Games: World of Warcraft add-ons, Roblox (which uses Luau, a version of Lua), or LÖVE, a free tool for making your own 2D games
  • Tools: the settings and plugins of the Neovim editor are written in Lua

To go deeper into the language itself, read Programming in Lua by Roberto Ierusalimschy, the main designer of Lua.

Throughout this course, you learned Lua's rules by running code and looking at the output. Lua is small, so you can test almost any idea in a few lines. Keep doing that.

Answer one last question about why programs embed Lua, and the course is complete. Well done!