The Very Basics

So, this is going to go over the VERY VERY VERY basics of lua in case you don't know it

but if you know absolutely nothing, I WOULD SERIOUSLY RECOMMEND LEARNING SOME FIRST AS THAT WILL MAKE THINGS SO MUCH EASIER FOR YOU! (but ill try to go over the basics just in case..)

Begin the tutorial

Back to basics

So the very basics of lua are, well, basic. If you've never programmed before then this may seem pretty foreign to you but bare with me as we get through this painful first part.


So, in programming, the very first thing we're going to want to know is the file extension of lua files, right?

If you couldn't guess it already, the file extension is .lua, so that would be tutorial.lua if you need a visualization.


Now that we got that out of the way, let's dive into the programming concepts.

The main thing you'll be using in programming are Variables

These are super important and you'll use them everywhere and all the time..


So what is a variable you may ask? Well in simple terms, it stores a value.

So, let's say we want to store a number for later use in our program. You could just place whatever number you want everywhere, like so:

test.lua
stuff(5)
do_things(5)
print(5)

and, while this will work, it's bad practice to do this and makes things way difficult. Plus, you'll need to use variables to store things that you don't know the value of beforehand, or that changes.

A better way to do this, would be this:

test.lua
my_number = 5
stuff(my_number)
do_things(my_number)
print(my_number)

What this allows us to do is have our number we want to use in ONE place, and we can just change the value to whatever we want, and it updates everywhere.


Now, another thing to note is that variables can store many different values. Such as, it can store numbers like that (Integers), it can store sentences (Strings), it can store True/False (Booleans).

Lua is Dynamic. Meaning, in other languages you may do String test = "yes!"; or test : String = "Yes!" but in lua, all you need to do is test = "yes!"

There is no type specification in lua so you can assign any variable any value and it will work fine with that. It figures out what kind of thing it is when you execute the code, which is useful in some ways, and bad in others. But that's for another guide


Now that we've covered variables, let's move on to statements & functions. Head on over to the Next Tutorial