Comments (Scripting): Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Mr Doom Bringer
m Comments moved to Comments (Scripting): Comments page should probably be regular site comments, redirects will go here, I'll fix links.
>Camoy
formatted; categorized
Line 1: Line 1:
__TOC__
==Comments==
===What are Comments?===


== Introduction ==
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.


This tutorial covers how to include comments in your script(s).
===Single-line Comments===
 
==Single-line comments==


A comment starts anywhere with a double hyphen (--) and runs until the end of the line:
A comment starts anywhere with a double hyphen (--) and runs until the end of the line:


<pre>
{{Example|<pre>
Example:
-- This is an example of a comment
-- This is an example of a comment
</pre>
</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.
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 ==
===Block Comments===


Lua also offers block comments, which start with the first double brackets and run until the corresponding double brackets:  
Lua also offers block comments, which start with the first double brackets and run until the corresponding double brackets:  


<pre>
{{Example|<pre>
Example:
--[[
    --[[
This is an example  
This is an example  
of a block comment.     
of a block comment.     
  --]]
  --]]
</pre>
</pre>}}


Notice how this comment is on more than one line.  In the first example, it is limited to one line.
Notice how this comment is on more than one line.  In the first example, it is limited to one line.


== See Also ==  
===See Also===
 
[http://www.lua.org/pil/1.3.html Lexical Conventions]


[http://www.lua.org/pil/1.3.html 1.3 - Some Lexical Conventions]
[[Category:Scripting_Tutorial]]

Revision as of 14:04, 1 November 2010

Comments

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
-- This is an example of a comment


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
--[[
This is an example 
of a block comment.    
 --]]


Notice how this comment is on more than one line. In the first example, it is limited to one line.

See Also

Lexical Conventions