Skip to reading
Lua Scripting

Names, comments and quoted text

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page

LESSON 02

Write the clue exactly as it should appear, including a quotation mark or a second line.

Code example
local Script = {}
Code example
function Script.run(context)
    -- A single-line comment ends at the newline.
    local owner = "Ada"
    local clue = 'The label reads "west".'
    local note = [[First bell: enter.
    Second bell: wait.]]
    --[[
    An author note can span lines.
    ]]
    local result = owner .. ": " .. clue .. "\n" .. note
    Log(result)
    return result
end
Code example
return Script

Lua names are case-sensitive. A name can contain letters, digits and underscores, with a letter or

underscore first. Scripts conventionally indent each block and put one statement on each line. Use

end to close a function or conditional.

Single and double quotes both create strings. Pick the one that needs fewer escapes. Within a

quoted string, \n makes a newline and \\ inserts one backslash. Long brackets preserve line breaks

and backslashes. Use [=[ and ]=] if the text must contain ]].

Try replacing the word west with east. Only the quoted clue should change.

Page 20 of 133Permalink
Go to page