Lua: Syntax

From Mario Fan Games Galaxy Wiki
Lua
Lua.gif
Basics
Intermediate
Advanced
XLua
Add to this template
 Standardwikimessagebox.png This article assumes the use of Lua 5.1.

Information may not be accurate or may need revision if you are using a different version.


 Stub.png This article or section is in need of expansion.

Please add further information.


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.