Learn the Lua C API fundamentals: how lua_State manages execution contexts, how the virtual stack works, and how to push, query, and pop values from C.
Tutorials
Lua Tutorials
Step-by-step series to learn Lua from scratch.
Lua C API
1 tutorial
- The Lua C API: Stack and State
Lua Coroutines
5 tutorials
- Coroutine Basics: Create, Resume, Yield
Learn Lua coroutine basics: create, resume, and yield coroutines for cooperative multitasking. Build iterators, task schedulers, handle pitfalls.
- Producer-Consumer with Coroutines
Implement producer-consumer coroutines in Lua for cooperative multitasking. Covers data pipelines, multiple producers, and when coroutines beat threads.
- 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 coroutine wrappers and iterators in Lua: generators, tree traversal, functional pipelines, and lazy file processing without manual state tracking.
- Async Patterns with Coroutines
Learn async patterns with Lua coroutines: producer-consumer pipelines, event loops, async/await simulation, and error handling for non-blocking operations.
Lua Data Structures
6 tutorials
- Stacks and Queues in Lua: Implementations and Performance
Build efficient stacks and queues in Lua using plain tables. Covers push and pop, the O(n) trap of table.remove(t, 1), and circular buffer performance.
- Implementing Sets in Lua Using Tables and Metatables
Hands-on guide to implementing sets in Lua: table keys as members, true sentinel values, union, intersection, difference, 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.
- Binary trees and binary search trees 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.
- Graph Representations in Lua: Adjacency Matrix and List
Learn two standard graph representations in Lua: adjacency matrices for dense graphs and adjacency lists for sparse graphs, with BFS and DFS traversal examples.
Lua Embedded
3 tutorials
- Embedding Lua in a C Application
Learn how embedding Lua in C works: create a Lua state, run scripts, exchange data through the stack, and register C functions for Lua to call.
- Extending Lua with C: how to write native modules
Extending Lua with C lets you write native modules that expose functions, userdata types, and metatables through the stack-based C API.
- Full Userdata and Light Userdata: Metatables in Lua
Learn the difference between full userdata and light userdata in Lua. Create garbage-collected C objects with metatables and metamethods for custom behavior.
Lua Fundamentals
13 tutorials
- Installing Lua on Windows, macOS, and Linux
Install Lua on macOS, Windows, and Linux — use Homebrew, Scoop, or your package manager to set up the interpreter and run your first script.
- Variables and Types in Lua: A Complete Guide
Learn Lua variables and types — local vs global scope, nil, boolean, number, string, function, table, userdata, thread. Practical examples for each.
- 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
Master Lua functions, closures, and varargs. Learn how to define functions, capture state with closures, and handle variable-length argument lists.
- Tables: Lua's Universal Data Structure
Master Lua tables — the language's only built-in data structure. Learn how Lua tables serve as arrays, dictionaries, and objects with practical code examples.
- Strings and Pattern Matching Basics
Master Lua strings pattern matching: concatenation, capturing, validation, and string patterns for gsub, gmatch, and text processing in Lua.
- Modules and the require System
Understand how Lua modules require and expose reusable code. Learn package.path usage, preload custom loaders, dependency management, and modern patterns.
- Error Handling with pcall and xpcall
Learn error handling in Lua using pcall and xpcall. Covers protected execution, error handlers, and when to use each function.
- Reading and Writing Files in Lua
Master reading writing files in Lua with the io library. Covers open modes, line iteration, append strategies, and best practices for safe file I/O.
- Pattern Matching in Lua: Strings, Captures, and Modifiers
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
Build hash maps in Lua with tables: string vs integer keys, `pairs()` vs `ipairs()`, the array part vs hash part, and metatable techniques.
- Lua arrays and lists: a complete table indexing guide
Master Lua arrays and lists by learning 1-based indexing, the # operator, table.insert, and how to build stacks, queues, and deques from plain tables.
Lua Gamedev Love2d
8 tutorials
- Getting Started with LOVE 2D: Installation and First Game
Getting started with LOVE 2D game development: install the engine on Windows, macOS, or Linux, understand the game loop, create windows, and draw shapes in Lua.
- Collision Detection Techniques
Learn collision detection techniques in LÖVE2D with AABB bounding boxes, circle collision tests, tile-based systems, and the Box2D physics module.
- Playing Music and Sound Effects in LÖVE2D
Learn to play music and sound effects in LÖVE2D games — load static and stream audio sources, control volume, pitch, looping, and 3D spatial positioning.
- Loading Tilemaps with STI in LÖVE2D
Load working tilemaps in Love2D with STI. Covers Tiled setup, animations, tile properties, custom layers, and Box2D collision integration for your game levels.
- Managing Game States and Scenes in LÖVE2D
Managing game states and scenes in LÖVE2D with hump.gamestate: handle menus, gameplay, pause screens, transitions, and save data across your game's lifecycle.
- Packaging and Distributing Your LÖVE2D Game
Packaging and distributing your LÖVE2D game: create .love files, fuse Windows executables, bundle for macOS and Linux, manage save files, release on itch.io.
- Drawing Animation and Sprites in LOVE 2D
Master drawing animation and sprite rendering in LOVE 2D: image loading, quad-based sprite sheets, frame-by-frame movement, and draw parameters.
- Keyboard, Mouse, and Gamepad Input
Handle keyboard mouse and gamepad input in LÖVE2D. Covers callbacks, scancodes, deadzones, and the gotchas beginners hit.
Lua OOP
5 tutorials
- Metatables: What They Are and Why They Matter
Metatables give Lua tables custom behavior through metamethods, covering __index, __newindex, operator overloading, read-only tables, and OOP foundations.
- 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.
- Every Lua Metamethod Explained
A complete reference to every Lua metamethod with runnable code examples. Learn arithmetic, comparison, index, and cleanup hooks in Lua 5.4.
- Single and Multiple Inheritance in Lua
Master inheritance in Lua using metatables, covering single and multiple inheritance patterns with practical code examples and common pitfalls.
- 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.
Lua Openresty
5 tutorials
- Getting Started with OpenResty
Get started with OpenResty — install on Linux, macOS, or Docker, then write Lua inside Nginx using the ngx API for routing, caching, and Redis-backed services.
- Routing and Middleware in OpenResty
Implement routing middleware in OpenResty with Lua scripts across Nginx request phases: rewrite, access, content, log.
- Building a REST API with OpenResty
Building REST APIs with OpenResty: routing, JSON handling, shared-dict caching, error recovery, external HTTP.
- 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.
- Using Redis from Lua in OpenResty
Use Redis Lua client lua-resty-redis in OpenResty: connection pooling, pipelining, Pub/Sub, transactions, ngx.null.
Lua Roblox
6 tutorials
- Getting Started with Roblox Luau
Getting started with Roblox Luau: learn variables, functions, tables, events, and build your first interactive game object in Studio.
- Scripting Game Objects and Services
A hands-on guide to scripting Roblox objects and services. Learn to create instances, use WaitForChild, and master RunService and TweenService.
- Building User Interfaces in Roblox
A hands-on guide to building user interfaces in Roblox. Learn ScreenGui, UDim2 positioning, interactive buttons, TweenService animations, and layout management.
- Saving Player Data with Roblox DataStores
Learn how saving player data works with Roblox DataStoreService: persist coins and inventory, handle auto-saving, and use ProfileService for session locking.
- Building a Complete Roblox Game
Build a complete Roblox coin collection game step by step. Covers leaderstats, DataStoreService persistence, RemoteEvents, and player UI creation.
- RemoteEvents and Client-Server Communication in Roblox
Master RemoteEvents and RemoteFunctions for client-server communication. Covers FireServer, FireClient, security validation, BindableEvents, and rate limiting.
Lua Testing
6 tutorials
- Getting Started with Testing in Lua
Getting started with testing in Lua: learn Busted for unit tests, assertions, setup/teardown hooks, stubs, spies, and running test suites from the command line.
- Using the Busted Test Framework
Learn how the Busted test framework brings BDD-style unit testing to Lua. Covers specs, spies, stubs, mocks, lifecycle hooks, tags, and CI configuration.
- Mocks, Stubs, and Spies in Lua
Mocks stubs spies in Lua: replace functions for unit tests. Covers manual test doubles, Busted stub/spy APIs, package.loaded.
- Measuring Code Coverage in Lua
Learn how measuring code coverage works in Lua with LuaCov and busted. Covers line and branch tracking, CI integration, and enforceable quality thresholds.
- Setting Up CI for Lua with GitHub Actions
Learn setting up CI for Lua projects with GitHub Actions. Run busted across Lua versions, cache dependencies, measure coverage, and enforce quality gates.
- Test-Driven Development Patterns in Lua
Learn test-driven development in Lua using busted. Covers Red-Green-Refactor, Arrange-Act-Assert, fixtures, dependency injection, and triangulation.
Neovim Lua
1 tutorial
- Scripting Neovim with Lua: From init.lua to Keymaps and Autocmds
Script Neovim with Lua — configure your editor using init.lua, set options, create keymaps and autocmds, and manipulate buffers and windows programmatically.