105 posts
Posted 05 May 2013 - 09:25 AM
I've got a question about
--
when i type it in a advanced computer that and the text behind it turns green.
what does it do/mean?
my speculation: it's a way to add text to a program wich doesn't do anything
26 posts
Location
Germany
Posted 05 May 2013 - 09:27 AM
The – Means that the text behind it (that is green) is a comment and is not used in the program.
For example :
turtle.forward() --Turtle moves forward
105 posts
Posted 05 May 2013 - 09:35 AM
ah, just a I thought.
thanks, now i can safely use it and not worry about having it screw up my program
799 posts
Location
Land of Meh
Posted 05 May 2013 - 09:59 AM
Just to add to that a bit:
--
In lua is single line comment. This means everything after it on the same line is ignored by the interpreter (basically, when the program is run, any comments are ignored). All languages (I can't think of one that doesn't) have comments in them. Usually, single line comments in other programs are made using two forwards slashes (//).
A single line comment isn't the only type of comment though. In Lua (and again, most other languages) there is also a block comment, which mean everything between –[[ and ]]– is treated as a comment, and ignored.
Example:
if true then -- This is a comment! It is ignored
-- This is also ignored
print("hello")
end
--[[ This is a block comment
all this text here
and here
and here
and even here
is ignored
up until here ->> ]]--
for i = 1, 10 do -- This code will execute because it's no longer in the block comment
print(i)
end
8543 posts
Posted 05 May 2013 - 12:24 PM
I believe block comments are unbalanced, actually. They go from –[[ to ]].