A Complete Guide to the Language Powering Games, Engines, and Embedded Systems
Introduction
- What This Book Is
- What This Book Is Not
- The Version Landscape
- How to Use the Code Examples
- A Note on Style
- What to Expect Next
Chapter 1: The Story of Lua
- From SOL to Lua: A Brazilian Origin Story
- Design Philosophy: Minimalism by Choice
- Version Evolution: From 1.0 to 5.5
- Where Lua Lives Today
- Chapter 1 Summary
Chapter 2: Getting Started with Lua
- Installing Lua: From Source to Package Manager
- Your First Lua Program
- Development Environments and Editors
- Understanding the Lua Distribution
- Chapter 2 Summary
Chapter 3: Lua Fundamentals: Types, Variables, and Expressions
- Lua’s Type System
- Variables and Assignment
- Operators and Precedence
- Strings and String Operations
- Chapter 3 Summary
Chapter 4: Control Flow
- Conditional Statements
- While and Repeat-Until Loops
- The For Loop: Numeric and Generic
- Blocks and the do-end Construct
- First-Class Functions
- Closures and Upvalues
- Variadic Functions and … Arguments
- Tail Calls and Proper Tail Call Optimization
- Table Operations and the Table Library
- Tables as Data Structures
- Table Traversal and Manipulation
- Chapter 6 Summary
Chapter 7: Metatables and Metamethods
- What Are Metatables?
- Arithmetic and Bitwise Metamethods
- Table Access Metamethods
- Advanced Metatable Patterns
- Metatable Lookup Chain: A Visual Guide
- Chapter 7 Summary
Chapter 8: Object-Oriented Programming in Lua
- Objects Without Classes
- Class Metapatterns
- Inheritance in Lua
- Encapsulation and Access Control
- Polymorphism and Duck Typing
- Why This Matters
Chapter 9: Modules, Packages, and Code Organization
- Creating Modules
- Package Paths and Searchers
- LuaRocks: The Package Ecosystem
- Chapter 9 Summary
Chapter 10: Coroutines and Cooperative Concurrency
- What Are Coroutines?
- Yielding and Resuming
- Producer-Consumer Patterns
- Practical Concurrency Patterns
- Why This Matters
Chapter 11: Error Handling, Debugging, and File I/O
- The Debug Library
- File I/O: Simple and Complete Models
- Pattern Matching with the String Library
- Performance Optimization Techniques
- Profiling and Benchmarking
- Garbage Collection Phases: A Visual Guide
- Chapter 12 Summary
Chapter 13: The C API, Embedding, and Extending Lua
- The C API Architecture
- Embedding Lua in C Applications
- Writing C Libraries for Lua
- Userdata and Metaprogramming in C
- Security and Sandboxing
- C API Stack: A Visual Guide
- Chapter 13 Summary
Mini-Project 3: C-Embedded Lua Scripting Host
- Design Overview
- Implementation
- Why This Matters
Chapter 14: Real-World Applications and Best Practices
- Game Development with Lua
- Web Development and Infrastructure
- Automation and Tooling
- Best Practices and Common Pitfalls
- Chapter 14 Summary
Conclusion
References
- Official Lua Documentation
- Language Design and Performance
- C API and Embedding
- Ecosystem and Tools
- Game Development
- Web Infrastructure
- Text Editors and Automation
- News and Analysis
- General References