CodeRigor

FREE COURSE / REAL PRACTICE

Lua programming

Learn values, tables, functions and modules before exploring metatables, iterators, coroutines and resource cleanup.

Free lessons & exercises9 authored lessons4 units

What you’ll work toward

Build small Lua programs with explicit interfaces, dependable iteration and controlled resource lifetimes.

Read an explanation, inspect the diagrams and work through the available checks, debugging exercises and builds. Feedback and prerequisite links guide the next step.

Before you start

The entry lesson has no earlier CodeRigor skill prerequisite. Start there and follow the sequence.

Individual lessons can add prerequisites. The course map shows your actual readiness.

A look inside the first lesson

Values, types & truthiness

Lua
for _, value in ipairs({false, 0, ""}) do
  print(type(value), value and "truthy" or "falsey")
end
print(type(nil), nil and "truthy" or "falsey")

Your course outline

Follow the lessons in curriculum order. Open a unit to preview the ideas you’ll work with.

UNIT 013 lessons Lua: values, functions & tables
  1. LESSON 01.01

    Values, types & truthiness

    Distinguish nil, false and truthy values, keep types explicit, and use local names in a Lua chunk.

    Open lesson
  2. LESSON 01.02

    Control flow, functions & multiple results

    Write local functions, validate preconditions and distinguish a function’s returned values from printed output.

    Open lesson
  3. LESSON 01.03

    Tables, sequences & missing entries

    Use table keys and explicit lengths without confusing nil holes, false values and sequence boundaries.

    Open lesson
UNIT 022 lessons Lua: parsing, modules & errors
  1. LESSON 02.01

    Strings, byte boundaries & Lua patterns

    Use anchored Lua patterns, explicit conversions and byte-aware string operations for a small record format.

    Open lesson
  2. LESSON 02.02

    Modules, local state & error contracts

    Export a module table, keep globals clean and choose returned error values or protected calls deliberately.

    Open lesson
UNIT 032 lessons Lua: metatables & iterators
  1. LESSON 03.01

    Metatables, lookup & proxy contracts

    Use lookup and assignment metamethods while understanding when raw table entries bypass them.

    Open lesson
  2. LESSON 03.02

    Closures, captured state & iterators

    Capture independent iterator state and use nil termination without confusing zero with absence.

    Open lesson
UNIT 042 lessons Lua: coroutines & resources
  1. LESSON 04.01

    Coroutines, yield & resume protocols

    Separate yielded values, completion and errors using resume results and coroutine status.

    Open lesson
  2. LESSON 04.02

    Files, errors & deterministic resource cleanup

    Read files without losing empty or final lines, report open failures and close handles deterministically.

    Open lesson