![]() ![]() The above probably looks a little weird, but that’s because we’re learning a new operator! The = operator checks for equality, whereas the = operator assigns a value. While on the subject, you can concat (cool-kid for concatenate) string literals and variables. NOTE: Yes, you can have several statements on the same line in Lua! The semi-colons are not necessary, I added them for extra readability. ![]() operator.Ī = “This “ b = “is “ c = “an “ d = “example.” Like arithmetic for numbers, one can concatenate strings (along with many other stuffs!) to combine several, using the. Similar to numbers, size does not matter, Lua can handle millions of characters within a string. String: any alphanumerical value, within quotation marks (“” or ”). Number: any numerical value, within a specific number range (a much bigger number than needs to be worried about)Īs we saw above, we can perform some basic arithmetic on numbers. So, we see here that variables can be numbers, which is one of the primary types in Lua. It takes the variable’s value, not the variable itself. If either variable (a or b) is changed after the assignment statement, the assigned variable’s (c) value (15) won’t change. If a variable is assigned to the values of some other variables (c = a + b), it will do the calculation and assignment the moment that the statement is called. I wanted to point out an important thing with this example. This is to specify what text is actually output. NOTE: From this point on, you’ll see → after out() calls. Let’s take the above code, and mess with it a little bit. They can be assigned to any type, change to any type, and they can infinitely change values. The coolest thing about variables is their dynamism. This instance (c = a + b) works a lot like algebra – you aren’t making “c = ab”, but you’re adding the value of a (10) to the value of b (5), to get the result of 15. In this case, variable a is assigned the value 10, variable b is assigned the value 5, and the variable c is assigned the value of a plus the value of b. We can see that each of those letters in the chunk above is a variable, which are each assigned a value. There are more, but we won’t need them.īut before going deeper into a definition, let’s look at an example: Lua types include: boolean, string, number, table, nil, function. Type: The sort of value that is in a variable. Variable: A custom-made keyword that can be used to represent a value NOTE: I recommend you have the Devtool Console handy to mess around with some of the stuff covered here.įollowing the concept of chunks and statements, the next most important subject to cover is variables, and types. ![]()
0 Comments
Leave a Reply. |