Hello World

Like with pretty much every other programming language tutorial, this will begin with the most simple program you can create: Hello World.

For the unaware, this program is quite simple: It prints out the text "Hello World" to the console.

In Lua, you print text to the console with a simple function: print(). To use it, simply put the string you want to print inside the (), as shown to the right.

And, believe it or not, that is really all there is to it. If you did it correctly, that outputted "Hello World!" to the console. Pretty neat, but not really all that useful.

You are also able to get input from the console from the user in Lua- with io.read(). This waits for text to be put into the console, and, when it is, it "returns" what was put in to the program. If you already know what that means, you may guess how to use it already. If not, it'll be gone over a bit later. In either case, we'll go over a simple way to use it in the next lesson. On that note, that's all for this lesson.

Oh, and a useful tip- you can create "comments" in Lua. These are not read by the program when it is running, so they can be used to store notes about your program in them. For single-line comments, use --, for multi-line comments, use --[[ ]]--. Example to the right.

print("Hello world!")

--single line comment

--[[
multi-line comment
]]--