Lua has a few basic types. So far you’re involved four of the types:
-
String
-
Number
-
Boolean (True/False)
-
Table
There are a few others. When you write out a number without quotes such as:
a = 2
You are assigning the “number” 2 to the variable a.
When you do a concatenation operator (…) you are basically writing:
ab = tostring(2) .. tostring(1)
Now the variable ab holds the “string” value of “21”. It does not hold the numeric value of 21. Lua is pretty good at converting numbers and strings back and forth for you, but you have to be careful because “21” does not equal 21.
If you want ab to hold the number 21, you do:
ab = 2 * 10 + 1
Rob