Comments
A comment is text that is completely ignored by the Lua parser — a parser converts the human-readable text in a script into structured data the computer can interpret.
Comments are commonly included by the programmer to clarify the intent of their code. A single-line comment can be made by inserting double dash --
. Anything after the --
on the same line will be turned into a comment.
-- This program causes a door to
-- close and open repeatedly,
-- at intervals of 2 seconds.
function onStart()
while true do
-- Call the close() function from the Door module
Door.close()
-- Call the wait() function from the Task module
Task.wait(2)
Door.open()
Task.wait(2)
end
end
A multi-line comment can be made by inserting --[[
before the comment and ]]
at the end of the comment.
--[[
This program causes a door to
close and open repeatedly,
at intervals of 2 seconds.
]]
function onStart()
while true do
-- Call the close() function from the Door module
Door.close()
-- Call the wait() function from the Task module
Task.wait(2)
Door.open()
Task.wait(2)
end
end