A small and concise guide for anyone who wants to learn Lua programming. Learn the basics of programming trough Lua regardless of your existing skill level.
This chapter covers what Lua is and how to set up a Lua environment on any operating system. Lua is not tied to any operating system, this chapter covers installing Lua for Windows, macOS, and Linux.
In this chapter, you will learn the basics of Lua programming. Topics such as variables, function data types, and loops are all going to be covered. By the end of this chapter, you should be familiar enough with Lua as a language to put together some simple programs.
The only data structure provided by Lua is the table. Tables are powerful enough to implement other data structures, such as lists, queues, or stacks. Lua is not object-oriented, however, using tables and meta-tables, an object system can be implemented from the ground up. By the end of this chapter, you will have implemented an object system in Lua.
This chapter will introduce the global table, some of Lua's built-in modules and how to create custom modules. By the end of this chapter, you should be able to put classes into modules to make them as reusable as possible.
Some of the properties that make Lua extremely powerful also make it easy to introduce unintended bugs. Sometimes, even the simplest of bugs can take a significant amount of effort to fix. Lua provides powerful debug libraries that help make these bugs easier to track down and resolve. In addition to debug libraries, a number of great external tools also exist.
In this chapter, we're going to focus on some of the common tasks involved in embedding Lua into any C or C++ application. While we are only focusing on the C API, Lua can be embedded into many languages using the same API.
The Lua C API is verbose and it can sometimes be a bit complicated to navigate. Furthermore, if you are programming in C++, the API doesn't really fit into the OOP idiom. There are a few binding libraries that try to bridge this gap. One of the most intuitive and easy-to-use libraries out there is Lua Bridge.
This last chapter focuses on looking ahead at where to go next. Several resources are provided to help the reader figure out new projects to take on.