Common Types
String
local variable1 = "Hello World." -- This is a number
local variable2 = 21 -- This is a number
-- This is a table with 2 elements
local variable3 = {
"Hello",
221,
}
Lua can be considered a loosely typed language. For example a string variable can be easily converted into a number or a table.
local var1 = 2017
function changeVar1()
var1 = "Two thousand and seventeen"
end
changeVar1()
This code snippet will convert var1 from a string type to a number type.
Lua, like most other languages, has the ability to provide comments in your code. You can provide single line and multiple line comments. Below are examples
-- This is an example of a single line comment
--[[This is
an example
of a multi-line comment.
--]]