Lua Tutorial Comments in Roblox Lua.

Andrew

New Coder
May 4, 2019
21
10
4
England, Sussex
A comment in lua text is completely ignored by the parser.
They can be useful to explain what a certain part of a script is doing, for example:

60
Comments in Roblox studio are usually coloured in green, but i changed my colour for the text.
What i just showed you is a short comment, you can start one with double hyphen (--).

You can also add Long Comments, we can define a opening with long brackets of level n as an opening square bracket followed by n equals symbol, then followed by another opening square bracket.An opening of a long bracket of level 0 is [[, and an opening long bracket of level 1 is written as [=[, and so on. Closing a long bracket is defined correspondingly; for instance, a closing of a level 4 is written as ]====]. Long comments starts with a opening long bracket of any level and ends at the first closing long bracket of the same level. Comments in this bracket can run through several lines and ignore any long brackets of any other level. They can contain anything expect from a closing bracket of the proper level.

Here is a example of a long comment:

Code:
--[===[
This is my very own long comment.
Guess what, it can contain hyphens like this --
Also contain long brackets other than it's own level like this:
And they can be closing long brackets like this: ]====]
Also thanks for reading this thread <3
]===]

 

Attachments

  • Like
Reactions: Malcolm

Malcolm

Administrator
Administrator
Jan 2, 2018
759
184
55
Canada
codeforum.org
It’s pretty neat how every coding/scripting/programming language is different in regards to using comments. You got HTML <!— —>, CSS /* */etc

Thank you for sharing this! Im sure this will help Coders with learning Lua.