User Tools

Site Tools



Lua syntax does not make use of many special symbols or mandatory formatting. Extra spaces may be added anywhere, and in most cases even line breaks are ignored. Comments in the source begin with --. Everything after the comment starter until the end of the line will be ignored. Or a comment can be enclosed in long-brackets if you want to have line breaks in it.

-- A single-line Lua comment
--[[ This comment
spans two lines ]]
--[==[ Another long comment ]==]

Long brackets begin with two left square braces and end with two right square braces. After the first brace you can add any number of equal signs. The number of equal signs between the two left braces must match the number of equal signs between the two right braces. That way, you can put a comment around text that has right square braces in it, and the long bracket block won’t end too early.

Lua statements can usually be written without line breaks. The end of one statement and the beginning of the next is determined without requiring a special separator. When you want to be sure that two statements are kept apart, you can insert a semi-colon (;) between the statements. This may be of more benefit to humans than the computer. A semi-colon is only allowed at the end of a statement. A statement may not be empty, so you cannot write two semi-colons in a row.

lgscript/lua_syntax.txt · Last modified: 2011/05/18 22:22 by telliamed