luaguides

Tutorial series

Lua Embedded

3 tutorials — follow in order for the best learning path.

  1. 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.

  2. 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.

  3. 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.