Return to Main Page

Comments

Page white text.png Description:This is an introduction to the lua language in general and is a recommended read if you are a beginner.
link=User:Dim1xs Author:Dim1xs
Calendar.png Created:September 30th 2023

Comments let you write notes for yourself in your script without affecting how your script works.

There are 2 types of comments:
Single-Line Comment and Multi-Line Comment.

Single-Line Comments

To do the comment you just have to type '--' And then type whatever you want! Everything after an -- is ignored by lua, until the next line of course.

--This var below, is a string. 
myName = "Dmitry"
               
You can also put a single line comment after a piece of code:

--This var below, is a string. 
myName = "Dmitry" --Name, is Dmitry. 
               
You can use a Single-Line comment to make lua ignore the line of code:

--This var below, is a string. 
myName = "Dmitry" --Name, is Dmitry. 
--print("Ignore ME!") 
               
This is called commenting out. It's just disabling code by making lua ignore it.

Multi-Line Comments

Multi-line comments allow you to comment out a large section of code with ease. This is useful for removing troublesome blocks or providing in-depth explanations as to what your code does. At it's most basic, a comment is a normal comment with a multiline string in it:

--[[
Multi-Line Comment
--]]
               

C-Style Comments

Coders in C-Languages will thank:

//Single-Line Comment 

//This var below, is a string. 
myName = "Dmitry" //Name, is Dmitry. 
//print("Ignore ME!") 

/*Multi
Line
Comment */

/*This var below, is a string. 
myName = "Dmitry"
print("Ignore ME!")*/ 
               

Thank you for reading this tutorial, see ya later!

JOIN HL2GMED DISCORD SERVER!