Learning Lua 101
This book teaches Lua as a first programming language for beginner readers. Lua is small, readable, and forgiving — a good fit for someone who has never written code before. The lessons build from nothing, so there is no assumed background. If you enjoy games, especially Roblox, the language is also directly useful: the final part of the book shows how everything you learned maps to Roblox Studio and Luau, the version of Lua that Roblox uses.
How the book is organised
The book is split into seven parts. Each part ends with a small project that only uses the things taught up to that point, so the reader is never asked to use a feature they have not seen yet.
- Part 1. Before you write code: what programming actually is, how to plan a program on paper with flowcharts, the three patterns every program is made of. No computer needed. Skip this part if you have written code before.
- Part 2. Getting started: installing Lua, running your first script, fixing your first error.
- Part 3. The basics: variables, strings, numbers, getting input from the keyboard.
- Part 4. Making decisions and repeating:
if, loops, the first real game. - Part 5. Data and reusable code: functions, tables, splitting code across files.
- Part 6. A taste of objects: methods,
self, simple object oriented programming with metatables. - Part 7. Bridge to Roblox: how the Lua you just learned shows up inside Roblox Studio, plus a small Studio project.
How each chapter is laid out
Each chapter has the same shape:
- A short explanation of one idea.
- Worked code examples that can be opened from the
exercises/folder and run on the reader's computer. - A few Try this prompts inside the chapter. These are one line changes meant to be answered immediately.
- A Homework section at the end with three to five problems and one optional Challenge.
- A separate homework solutions page (linked at the end of the homework section) that explains how to think about each problem, then shows a worked solution and common mistakes.
What you need
- For Part 1: just a sheet of paper and a pencil.
- For Parts 2 onwards: a computer running Windows 10 or 11, an internet connection long enough to install Lua and a text editor, and a keyboard.
The next chapter starts Part 1 by asking what a program actually is. If you have written code before and want to skip ahead, the Setup chapter installs Lua and your editor.