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.
Tutorial series
Lua Embedded
3 tutorials — follow in order for the best learning path.
- Embedding Lua in a C Application
- 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.