Learn how to install Lua on any operating system, verify your installation, and write your first Lua script.
Tutorial series
Lua Fundamentals
13 tutorials — follow in order for the best learning path.
- Installing Lua on Windows, macOS, and Linux
- Variables and Types in Lua
Learn how Lua handles variables, understand the difference between local and global variables, and explore Lua's eight basic data types.
- Control Flow in Lua: if, for, while, and repeat
Master Lua control flow with if/elseif/else, for loops, while loops, and repeat...until. Build decision-making into your programs.
- Functions, Closures, and Varargs
Learn how to define and use functions in Lua, including closures, variadic arguments, and best practices for writing modular code.
- Tables: Lua's Universal Data Structure
Learn how tables in Lua work as arrays, dictionaries, and objects—all in one powerful data structure.
- Strings and Pattern Matching Basics
Learn how to work with strings in Lua using the string library and pattern matching with Lua's powerful pattern syntax.
- Modules and the require System
Learn how to organize Lua code into reusable modules using require, package.path, and best practices for dependency management.
- Error Handling with pcall and xpcall
Learn how to handle errors safely in Lua using pcall and xpcall. Covers protected execution, error handlers, and when to use each function.
- Reading and Writing Files in Lua
Learn how to read and write files in Lua using the io library...
- Pattern Matching Deep Dive
Learn Lua pattern matching syntax for searching, extracting, and transforming strings with character classes, captures, and practical examples.
- Operator Overloading with Metamethods
Learn how metatables and metamethods enable operator overloading in Lua, letting you define custom behavior for your own tables.
- Hash Maps and Dictionaries in Lua
Learn how Lua tables store key-value pairs, choose the right iteration method, and apply metatable tricks for advanced patterns.
- Arrays and Lists in Lua
Learn Lua tables as arrays: 1-based indexing, the # operator, table.insert, table.remove, table.concat, and building stacks, queues, and deques.