Lua scripting for game development, embedded systems, and configuration. Use for .lua files.
A powerful, efficient, lightweight, embeddable scripting language.
print("Hello, World!")
function factorial(n)
if n == 0 then
return 1
else
return n * factorial(n - 1)
end
end
The only complex data structure in Lua. Used as arrays, dictionaries, sets, and objects.
t = { key = "value", [1] = "first" }
print(t.key)
Allow changing the behavior of tables (e.g., operator overloading, inheritance).
Arrays are 1-indexed (start at 1, not 0).
Do:
local variables by default (performance and scope)# behavior with holesDon't:
nil (undefined variables are nil)