Lua: Syntax
From Mario Fan Games Galaxy Wiki
Lua |
---|
Basics |
Intermediate |
Advanced |
|
XLua |
Add to this template |
Lua syntax is relatively simple due to Lua's smaller direct library of features. Most of these features are, in practice, similar to those of other languages such as C or PHP.
Chunks and blocks
A chunk is a bunch of statements one after the other in no particular hierarchy:
print("text") -- Part of a chunk
print("text") -- Part of a chunk
print("text") -- Part of a chunk
print("text") -- Part of a chunk
A block is a family of statements belonging to a function:
do
print("Hello World") -- Part of a block
end
Variables defined within a do block are local to that block, and cannot be accessed from outside of it.