Lua: Syntax
From Mario Fan Games Galaxy Wiki
Lua |
---|
Basics |
Intermediate |
Advanced |
|
XLua |
Add to this template |
Lua's syntax is quite simple; given its small feature set compared to other languages, it has a much smaller collection of syntax elements. However, much of what it does have is not much different than other languages.
Chunks and Blocks
A chunk is basically a group of statements. A block is much the same thing, but is surrounded by special keywords that are like curly brackets in other languages. One of these is end, which closes all blocks, and the word beginning a block may vary depending on what the block does. for, do, if, and function are common, though there are a few others. One such block may look like:
do print("Hello World") end
do blocks are useful as they can be used to limit the scope of local variables; local variables will only be visible within that block.