|
|
(27 intermediate revisions by 5 users not shown) |
Line 1: |
Line 1: |
| ==Comments==
| | #redirect [[Comment (Scripting)]] |
| ===What are Comments?===
| |
| | |
| Comments are exactly what they sound like, they're comments. They are there just for organizing code and such. Lua will not do anything with these comments.
| |
| | |
| ===Single-line Comments===
| |
| | |
| A comment starts anywhere with a double hyphen (--) and runs until the end of the line:
| |
| | |
| {{Example|<pre>
| |
| -- This is an example of a comment
| |
| </pre>}}
| |
| | |
| Comments do not appear in the output window. They are mostly to help the programmer understand what a section of code is for in long, complicated scripts.
| |
| | |
| ===Block Comments===
| |
| | |
| Lua also offers block comments, which start with the first double brackets and run until the corresponding double brackets:
| |
| | |
| {{Example|<pre>
| |
| --[[
| |
| This is an example
| |
| of a block comment.
| |
| ]]
| |
| </pre>}}
| |
| | |
| ===Leveled Comments===
| |
| | |
| Leveled comments are comments that have different levels of toleration for lower-leveled comments, such as the above block comment.
| |
| | |
| {{Example|<pre>
| |
| --[=[
| |
| This is a level 1 comment.
| |
| ]=]
| |
| </pre>
| |
| | |
| Below is a level 2 comment, there is no limit to what level a comment is on. But a level 1 comment cannot hold a level 2 or higher, and so forth...
| |
| <pre>
| |
| --[==[
| |
| This is a level 2 comment.
| |
| ]==]
| |
| </pre>}}
| |
| | |
| Notice how this comment is on more than one line. In the first example, it is limited to one line.
| |
| | |
| ==See Also==
| |
| | |
| *[http://www.lua.org/pil/1.3.html Lexical Conventions]
| |
| * [[Comments|Generic Comments on the Website]]
| |
| * [[Place#Turn_comments_on.2Foff|Turning off place comments]]
| |
| | |
| [[Category:Scripting_Tutorials]] | |