Learn the two main ways to represent graphs in Lua: adjacency matrices and adjacency lists, with BFS and DFS implementations.
Tutorials
Tutorials
Step-by-step series to learn Lua from scratch.
- Graph Representations in Lua
- The Lua C API: Stack and State
Learn how Lua manages state with lua_State, how the virtual stack works, and how to push, query, and pop values from C.
- Coroutine Basics: Create, Resume, Yield
Learn how to create, resume, and yield from Lua coroutines for cooperative multitasking.
- Producer-Consumer with Coroutines
Learn how to implement the producer-consumer pattern in Lua using coroutines for efficient cooperative multitasking.
- Cooperative Multitasking Patterns
Learn how to build cooperative multitasking workflows in Lua using coroutines with producer-consumer, scheduler, and pipeline patterns.
- Coroutine Wrappers and Iterators
Discover how to use coroutine wrappers and iterators in Lua to build efficient generators and custom traversal functions.
- Async Patterns with Coroutines
Learn how to implement asynchronous programming patterns using Lua coroutines for non-blocking operations
- Binary Trees and BSTs in Lua
Learn how to implement binary trees and binary search trees in Lua with clear explanations and runnable code examples.
- Priority Queues and Heaps in Lua
Learn how to implement priority queues and binary heaps in Lua using tables, with practical examples for task scheduling and event queues.
- Embedding Lua in a C Application
Learn how to embed a Lua interpreter into your C programs to run Lua scripts, exchange data via a stack, and expose C functions to Lua.
- Writing C Extensions for Lua
Learn how to write C modules that Lua can load with require(), covering stack management, module registration, userdata, and compilation.
- Userdata, Light Userdata, and Metatables in Lua
Learn how Lua bridges C code with userdata types and uses metatables to define custom behavior for any value.
- Installing Lua on Windows, macOS, and Linux
Learn how to install Lua on any operating system, verify your installation, and write your first Lua script.
- 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.
- Getting Started with LOVE 2D
Install LOVE 2D, understand the game loop, create windows, and draw your first shapes in Lua.
- Collision Detection Techniques
Learn how to detect collisions between game objects in LÖVE2D using AABB, circle, and tile-based methods.
- Playing Music and Sound Effects in LÖVE2D
Learn how to load, play, and control audio in LÖVE2D — from background music with looping to sound effects with volume and pitch control.
- Working with Tilemaps and STI
Learn how to load, render, and manipulate tile maps in Love2D using the STI library
- Managing Game States and Scenes
Learn how to structure your LÖVE games using hump.gamestate to handle menus, gameplay, pause screens, and transitions between parts of your application.
- Packaging and Distributing Your Game
Learn how to package your LÖVE2D game into a .love file, create Windows executables, macOS app bundles, and distribute on itch.io.
- Every Lua Metamethod Explained
A complete guide to every metamethod in Lua 5.4: arithmetic, comparison, __index, __call, __gc, __close, and more with runnable examples.
- Metatables: What They Are and Why They Matter
Learn how metatables let you customize table behavior in Lua — from operator overloading to OOP inheritance and read-only tables.
- Building Classes in Lua with Metatables: OOP Step by Step
Guide to building classes in Lua with metatables. Covers constructors, methods, the self parameter, private members, and inheritance patterns step by step.
- Single and Multiple Inheritance in Lua
Learn how to implement inheritance in Lua using metatables, covering single and multiple inheritance patterns with practical examples.
- Mixins and Composition Patterns in Lua
Learn how to use mixins and composition in Lua to add functionality to objects without the constraints of traditional inheritance.
- Getting Started with OpenResty
Learn how to build powerful web applications and API gateways using OpenResty—the platform that combines Nginx with LuaJIT for dynamic request processing.
- Routing and Middleware in OpenResty
Learn how OpenResty processes HTTP requests through phases, and how to implement routing and middleware using Lua scripts embedded in Nginx.
- Building a REST API with OpenResty
Learn how to build a REST API with OpenResty and Lua, covering routing, request handling, JSON responses, and caching with shared dicts.
- Getting Started with Roblox Luau
Learn the basics of Luau scripting in Roblox Studio, from variables and functions to handling events and building your first interactive game object.
- Scripting Game Objects and Services
Learn how to create, navigate, and manipulate Roblox game objects using Luau, from the object hierarchy to key services and practical patterns.
- Building User Interfaces in Roblox
Learn how to create interactive user interfaces in Roblox using ScreenGui, frames, text elements, and the TweenService animation API.
- Mocks, Stubs, and Spies in Lua
Learn how to replace functions with test doubles in Lua using manual patterns and Busted's built-in stub and spy APIs for reliable unit tests.
- Measuring Code Coverage in Lua
Learn how to track which lines of your Lua code run during tests using LuaCov and busted's built-in coverage reporting.
- Setting Up CI for Lua with GitHub Actions
Automate your Lua tests with GitHub Actions. Run busted on multiple Lua versions, measure coverage with lua-cov, and enforce quality gates in CI.
- Test-Driven Development Patterns in Lua
Learn to drive your Lua code design through tests. Covers Red-Green-Refactor, Arrange-Act-Assert, fixtures, stubs, and TDD patterns with busted.
- Getting Started with Testing in Lua
Learn how to write and run unit tests in Lua using the Busted framework, from basic assertions to setup/teardown and stubbing.
- Using the Busted Test Framework
Learn how to write, run, and organize unit tests in Lua with the Busted BDD framework, including spies, stubs, mocks, and lifecycle hooks.
- Scripting Neovim with Lua
Learn how to configure and extend Neovim using Lua — from your first init.lua to working with buffers, windows, autocmds, and keymaps.
- Using Redis from Lua in OpenResty
Learn how to connect to Redis from OpenResty using lua-resty-redis — covering connection management, get/set ops, pipelining, Pub/Sub, and pooling.
- Rate Limiting with Lua and Shared Dicts
Learn how to implement rate limiting in OpenResty using ngx.shared.DICT, covering fixed window counters, token buckets, and lua-resty-limit-traffic.
- RemoteEvents and Client-Server Communication in Roblox
Learn how RemoteEvents and RemoteFunctions bridge the gap between Roblox server scripts and client scripts for multiplayer game communication.
- Saving Player Data with DataStores
Learn how to use Roblox DataStoreService to persist player coins, inventory, and progress between sessions.
- Building a Complete Roblox Game
Build a coin collection game in Roblox Studio from scratch — covering leaderstats, DataStoreService persistence, RemoteEvents, and player UI.
- Stacks and Queues in Lua
Implement stacks and queues in Lua using tables. Learn push/pop, the O(n) trap with table.remove(t, 1), and how to build an efficient circular buffer.
- Implementing Sets in Lua
Learn how to implement and use sets in Lua using tables with true sentinel values, including set operations, iteration gotchas, and read-only proxies.
- Singly and Doubly Linked Lists in Lua
Learn how to implement singly and doubly linked lists in Lua using tables, with performance comparisons and practical examples.