Lua Exercises 1

This article will be a bit shorter, but has some exercises to practice what we’ve covered so far as well as some other tricks for algorithms and similar outside of the language itself. The goal is to both grow language skills as well as growing our programming skills. Some exercises include extra information and Lua specific tricks.

Exercise 1

John has a store and wants a program to give him the total for a purchase.… Read the rest

Basics of Lua Functions and Recursion

Lua makes use of functions in order to extend the language and to make code a bit cleaner. This section will go over the basics of functions in Lua as well as some basic recursion. We will also look at how to import code into a file in order to make things cleaner.

Introduction to Functions

Basic function definition in Lua is dead simple.… Read the rest

Bringing More to the Table with Lua (Part 2)

This is the sixth entry in my Lua Tutorial series. See here for an introduction for this series, or here for our previous entry covering using tables as arrays.

We’re going to cover using tables as hash tables which are a bit different than arrays. Hash tables or hash maps are the basis of many useful data structures. Ultimately, they end up being basically arrays on the back end with a way to map and retrieve values based on keys.… Read the rest

Bringing More to the Table with Lua (Part 1)

This is the fifth entry in my Lua Tutorial series. See here for an introduction for this series, or here for our previous entry covering loops and similar.

Tables are an integral data structure in Lua. They operate like both standard arrays and like hash tables in other languages. They have a huge number of uses and some really cool features, but for the time being, we’re just going to introduce them as a basic data structure and see a bit of what they can do.… Read the rest