Lua
From DocForge
LUA is an interpreted language, intended to be easily embedded as a script within other applications.
Contents |
[edit] Variables
LUA is a dynamically typed language.
There are eight data types in LUA: nil, boolean, number, string, function, userdata, thread, and table. The first five are self-explanitory, however:
- userdata represents arbitrary data; which cannot be manipulated within LUA beyond assignment or memory testing.
- thread represents an internal LUA thread for coroutines. Not to be confused with operating system threads
- table represents arrays.
[edit] Strings
Strings are delimited with either the ' or " characters. For long-format strings, they may start with [[ and finish with ]]. The square brackets may also contain equals signs (e.g. [==[ and ]==])
[edit] Flow control
- while <expression> do ... end
- repeat ... until <expression>
- if <expression> then ... {elseif <expression> then ...} [else ...] end
- for <value> = <start>, <end>, [, <step>] do block end
[edit] Functions
function f() [body] end
Functions allow a variable number of arguments
function f(...)
If used in the parameter list, any extra parameters are stored as an array and accessed with the token ...