User:Merlin11188/Draft: Difference between revisions
>Merlin11188 Wrote a small page for the 'TextScaled' property. |
>Merlin11188 Began work on tutorial |
||
Line 3: | Line 3: | ||
|<big>'''Do not edit!'''</big><br><small>The creator of this subpage does not want it to be edited without permission.</small> | |<big>'''Do not edit!'''</big><br><small>The creator of this subpage does not want it to be edited without permission.</small> | ||
|} | |} | ||
==Hello World== | |||
The language I'm teaching you is called ''Lua''. A tradition of programming languages is to start off the learner with a ''Hello World'' program. So what is a ''Hello World'' program? It is a program that writes the words "Hello World" to the [[Output|output]]. Here it is in Lua: | |||
{{Example|{{Code and output|code= | |||
print("Hello World") | |||
|output= | |||
Hello World | |||
|fit=output}}}} | |||
{{Example| | Ta-da! For now and the rest of the tutorial, that box on the left is the output. Keep that in mind. [[Function_Dump/Core_Functions#print_.28.C2.B7.C2.B7.C2.B7.29|Print]] is our function for writing to the output. When we want to print string literals (words, like ''Hello World'') to the output, we '''must''' put them in quotes. Here's another example: | ||
</code | {{Example|{{Code and output|code= | ||
print("Hi Newcomer!") | |||
|output= | |||
Hi Newcomer! | |||
|fit=output}}}} | |||
__TOC__ | |||
==Beginning== | |||
===Terminology=== | |||
There are three terms I want you to know before we continue: | |||
*{{`|code}} refers to '''anything''' written in Lua. | |||
*{{`|chunk}} refers to '''one''' line of {{`|code}} in Lua. | |||
*{{`|script}} refers to '''multiple''' {{`|chunk}}s that accomplish a specific task in Lua. | |||
*{{`|character}} refers to any of the [http://wiki.roblox.com/index.php/File:Ascii_Table.png ASCII Values] (numbers, letters, spaces, enter key, down arrow, etc.) | |||
===Comments=== | |||
Before I start explaining the stuff you can do in Lua to you, there is something I need to explain to you that I'm going to use a lot in this tutorial: ''Commenting''. Comments are things that are '''not''' executed by Lua. A comment can contain any characters because it doesn't need to be read. | |||
====One-Line comments==== | |||
A one-line comment is made with {{`|--}}. It lasts for the rest of the line. Here are some examples: | |||
{{Example|{{Code and output|code= | |||
print("Hello world") -- This will print Hello world to the output! | |||
-- I'm invisible! print("Hi"). Hi won't be printed to the output! | |||
|output= | |||
Hello world | |||
|fit=output}}}} | |||
====Multi-Line Comments==== | |||
A multi-line comment starts with --[[ and ends with <nowiki>]]</nowiki>. Everything between the opening and the closing is treated as a comment, even if the comment is only in the middle of the line. | |||
{{Example|{{Code and output|code= | |||
print("Hello World")--[[ | |||
I'm a very long comment. | |||
In fact, I last multiple lines. | |||
Should I be discovered, I must… but that won't happen. | |||
]]|output= | |||
Hello World | |||
|fit=output}}}} | |||
''A multi-line comment '''cannot''' be placed inside of a string literal (inside of quotation marks)!'' You must put it elsewhere. Here are more examples: | |||
{{Example|{{Code and output|code= | |||
print("Hello M--[[I'll never be found!]]y Friend!") | |||
--[[They'll never catch me!]]print("HI") | |||
|output= | |||
Hello M--[[I'll never be found!]]y Friend! | |||
HI | |||
}}}} |
Revision as of 05:31, 22 January 2012
Do not edit! The creator of this subpage does not want it to be edited without permission. |
Hello World
The language I'm teaching you is called Lua. A tradition of programming languages is to start off the learner with a Hello World program. So what is a Hello World program? It is a program that writes the words "Hello World" to the output. Here it is in Lua:
Ta-da! For now and the rest of the tutorial, that box on the left is the output. Keep that in mind. Print is our function for writing to the output. When we want to print string literals (words, like Hello World) to the output, we must put them in quotes. Here's another example:
Beginning
Terminology
There are three terms I want you to know before we continue:
- code refers to anything written in Lua.
- chunk refers to one line of code in Lua.
- script refers to multiple chunks that accomplish a specific task in Lua.
- character refers to any of the ASCII Values (numbers, letters, spaces, enter key, down arrow, etc.)
Comments
Before I start explaining the stuff you can do in Lua to you, there is something I need to explain to you that I'm going to use a lot in this tutorial: Commenting. Comments are things that are not executed by Lua. A comment can contain any characters because it doesn't need to be read.
One-Line comments
A one-line comment is made with --. It lasts for the rest of the line. Here are some examples:
Multi-Line Comments
A multi-line comment starts with --[[ and ends with ]]. Everything between the opening and the closing is treated as a comment, even if the comment is only in the middle of the line.
A multi-line comment cannot be placed inside of a string literal (inside of quotation marks)! You must put it elsewhere. Here are more examples: