Chapter 2: Writing Better Code
This chapter is all about using what we learned in the previous chapter and taking it to the next level. In this chapter, we will start by looking at functions. We will learn how and when to use them. Functions allow us to reduce the amount of duplicate code in our scripts. Once we have gained an understanding of this, we will then continue by looking at tables. Tables allow us to store a lot of data in just one variable. Once we have understood tables, we will start using loops. We will learn about all the different loops that Luau has. Besides that, we will use these loops in the tables that we make. Toward the end of the chapter, we will also explain modules. Modules allow us to write less duplicate code spread over multiple scripts.
In this chapter, we will cover the following topics:
- Using functions
- Storing data types in tables
- Programming loops
- Using modules
- Exercises
By the end of this chapter, you will have learned...