<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://www.computercraft.info/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=My+hat+stinks</id>
		<title>ComputerCraft Wiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://www.computercraft.info/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=My+hat+stinks"/>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/Special:Contributions/My_hat_stinks"/>
		<updated>2026-07-11T09:03:40Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.24.1</generator>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Class&amp;diff=6841</id>
		<title>Class</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Class&amp;diff=6841"/>
				<updated>2015-02-11T15:57:38Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Fixed code format&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Classes''' can be created in Lua to simplify the creation of large projects by using objects. In Lua, an '''object''' is a [[tables|table]] which has data and can make use of '''methods''' ([[Function (type)|functions]] for classes) which are designed to work with the object's data to carry out potentially large or complicated tasks with a minimum of code. Classes are not required for making simple projects, but can be helpful to have when using or creating large projects and APIs, especially when working with other programmers.&lt;br /&gt;
&lt;br /&gt;
== Basics of classes ==&lt;br /&gt;
In Lua, classes are built as '''prototype''' tables which contain methods and data that other tables can refer to. The simplest example is as follows:&lt;br /&gt;
&lt;br /&gt;
 -- Example 1&lt;br /&gt;
 Prototype1 = {color=&amp;quot;black&amp;quot;}&lt;br /&gt;
 local instance1 = {}&lt;br /&gt;
 setmetatable (instance1, {__index=Prototype1})&lt;br /&gt;
 print (instance1.color)&lt;br /&gt;
&lt;br /&gt;
In this example, the program will print &amp;quot;black&amp;quot;. This is because we've changed instance1 so that whenever we try to find an attribute that it doesn't have already, it will default to whatever Prototype1 uses for that attribute. Since we never defined instance1.color, it defaults to Prototype1.color which is &amp;quot;black&amp;quot;. We can say that instance1 is an object, or that it is an '''instance''' of Prototype1.&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
Methods are the real reason for creating classes. At the most basic, this can be done as such:&lt;br /&gt;
&lt;br /&gt;
 -- Example 2&lt;br /&gt;
 ImagePrototype = {data={}}&lt;br /&gt;
 &lt;br /&gt;
 function ImagePrototype.printData (instance)&lt;br /&gt;
   print (instance.data)   &lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local image1 = {data=&amp;quot;1,1,Black;&amp;quot;}&lt;br /&gt;
 setmetatable (image1, {__index=ImagePrototype})&lt;br /&gt;
 ImagePrototype.printData(image1)&lt;br /&gt;
&lt;br /&gt;
This program will print &amp;quot;1,1,black;&amp;quot;. We can make it a little bit more efficient if we use colons ':'. Although all attributes of table and objects can be accessed like objectName [&amp;quot;attributeName&amp;quot;] or objectName.attributeName, there is a special trick we can use for methods. Using a colon, we can say objectName:methodName() and we will automatically make it so that the first variable we give the method is the object that we were referring to. In addition, we can use this trick when we write methods. By saying className:methodName, the method will automatically have an initial variable called self. 'Self' is the standard term used across many programming languages to refer to the object that a method is working with. Here's an example of how we can simplify this code:&lt;br /&gt;
&lt;br /&gt;
 -- Example 3&lt;br /&gt;
 ImagePrototype = {data={}}&lt;br /&gt;
 &lt;br /&gt;
 function ImagePrototype:printData ()&lt;br /&gt;
   print (self.data)   &lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local image1 = {data=&amp;quot;1,1,Black;&amp;quot;}&lt;br /&gt;
 setmetatable (image1, {__index=ImagePrototype})&lt;br /&gt;
 image1:printData()&lt;br /&gt;
&lt;br /&gt;
Now we still still print &amp;quot;1,1,Black;&amp;quot;, but we've made things a little bit neater and easier.&lt;br /&gt;
&lt;br /&gt;
=== Initialization ===&lt;br /&gt;
Instead of using setmetatable after every time we create an instance, we can simplify things a little bit more by including that process in the class with an initialization function. Here's an example:&lt;br /&gt;
&lt;br /&gt;
 -- Example 4&lt;br /&gt;
 ImagePrototype = {data={}}&lt;br /&gt;
 &lt;br /&gt;
 function ImagePrototype.__init__ (data)&lt;br /&gt;
   local self = {data=data}&lt;br /&gt;
   setmetatable (self, {__index=ImagePrototype})&lt;br /&gt;
   return self&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 function ImagePrototype:printData ()&lt;br /&gt;
   print (self.data)   &lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local image1 = ImagePrototype.__init__ (&amp;quot;1,1,Black;&amp;quot;)&lt;br /&gt;
 image1:printData()&lt;br /&gt;
&lt;br /&gt;
Now we're still printing &amp;quot;1,1,Black;&amp;quot;, but we only need one line of code to create an instance of ImagePrototype, and one line to do the printing. The last two lines in this example involve a lot less writing than the last three lines in example 2.&lt;br /&gt;
&lt;br /&gt;
=== Callable classes ===&lt;br /&gt;
We can simplify things even further and achieve some interesting results by making classes act like functions. To do this, we use setmetatable again, but now we're changing __call instead of __index. Here's an example:&lt;br /&gt;
&lt;br /&gt;
 -- Example 5&lt;br /&gt;
 ImagePrototype = {data=&amp;quot;Original&amp;quot;}&lt;br /&gt;
 &lt;br /&gt;
 function ImagePrototype.__init__ (baseClass, data)&lt;br /&gt;
   self = {data=data}&lt;br /&gt;
   setmetatable (self, {__index=ImagePrototype})&lt;br /&gt;
   return self&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 setmetatable (ImagePrototype, {__call=ImagePrototype.__init__}) --Makes ImagePrototype(...) act like ImagePrototype.__init__ (ImagePrototype, ...)&lt;br /&gt;
 &lt;br /&gt;
 function ImagePrototype:printData ()&lt;br /&gt;
   print (self.data)   &lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local image1 = ImagePrototype (&amp;quot;1,1,Black;&amp;quot;)&lt;br /&gt;
 image1:printData()&lt;br /&gt;
&lt;br /&gt;
Now we get the same output, but the last two lines have become even simpler, especially when compared with the last three lines in example 2.&lt;br /&gt;
&lt;br /&gt;
Callable classes can also be used in other cases, for example if you want to make a class which acts like a function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;Should add information about [http://lua-users.org/wiki/ObjectProperties getters and setters], private attributes, inheritance, superclasses, [http://lua-users.org/wiki/DecoratorsAndDocstrings decorators and docstrings], etc.&amp;lt;/noinclude&amp;gt; &lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Metatable]]&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
* Official Lua documentation for object-oriented programming:&lt;br /&gt;
** [http://www.lua.org/pil/16.html 1.6: Object-Oriented Programming]&lt;br /&gt;
** [http://www.lua.org/pil/16.1.html 1.6: Classes]&lt;br /&gt;
** [http://www.lua.org/pil/16.2.html 1.6: Inheritance]&lt;br /&gt;
** [http://www.lua.org/pil/16.3.html 1.6: Multiple Inheritance]&lt;br /&gt;
** [http://www.lua.org/pil/16.4.html 1.6: Privacy]&lt;br /&gt;
** [http://www.lua.org/pil/16.5.html 1.6: The Single-Method Approach]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Tables&amp;diff=6840</id>
		<title>Tables</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Tables&amp;diff=6840"/>
				<updated>2015-02-11T15:54:06Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: /* Using the Table */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Tutorial&lt;br /&gt;
|name=Tables&lt;br /&gt;
|desc=This script will introduce you to Tables, and show you some ways to use them. If you have experience with other languages, a table is roughly equivalent to an array.&lt;br /&gt;
|objective=An understanding of the usage and purpose of Tables&lt;br /&gt;
|prereqs=[[Variables|A basic understanding of Variables]].&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Why are Tables Useful? ==&lt;br /&gt;
&lt;br /&gt;
Tables can simplify code considerably, by grouping like variables and functions together.&lt;br /&gt;
&lt;br /&gt;
In this example, we're getting a list of student's names&lt;br /&gt;
Code without tables&lt;br /&gt;
 local StudentName1 = &amp;quot;Andrew&amp;quot;&lt;br /&gt;
 local StudentName2 = &amp;quot;Alfred&amp;quot;&lt;br /&gt;
 local StudentName3 = &amp;quot;Alex&amp;quot;&lt;br /&gt;
 local StudentName4 = &amp;quot;Amber&amp;quot;&lt;br /&gt;
 local StudentName5 = &amp;quot;Alice&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Code with tables&lt;br /&gt;
 local StudentNames = {&amp;quot;Andrew&amp;quot;, &amp;quot;Alfred&amp;quot;, &amp;quot;Alex&amp;quot;, &amp;quot;Amber&amp;quot;, &amp;quot;Alice&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
As you can see, the first example needs 5 unique variables being defined individually, while the second example, using the table, is all one line with one variable.&lt;br /&gt;
&lt;br /&gt;
Note the { and }, this is how you spot a table. Anything between them is a variable to be stored in the table. A table is not restricted to one variable type, and you can even store tables within tables if you wish&lt;br /&gt;
&lt;br /&gt;
== Using the Table ==&lt;br /&gt;
&lt;br /&gt;
There are a number of ways to set the values in a table. The first, as shown above, is the simplest method, and will give each value a unique number as the &amp;quot;key&amp;quot;. The key is simply the location in the table, it's usually a number or string. This method always clears the contents of the table and replaces it with what you've specified. Note that setting a table to &amp;quot;{}&amp;quot; is valid, and is commonly used if the values don't need to, or can't, be set immediately. You may find yourself using &amp;quot;Variable={}&amp;quot; often. Setting a specific key with this method is relatively simple, you just use the asignment operator &amp;quot;=&amp;quot; and treat the key as a variable&lt;br /&gt;
 local Table = {Key1 = &amp;quot;First key!&amp;quot;, Key2 = &amp;quot;Second key!&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
It can also be defined over multiple lines, to help with readability, if you end the line with a comma rather than the } to close it. Just remember to add the } when you're done.&lt;br /&gt;
 local Table = {&amp;quot;Stuff&amp;quot;, 1, 2, &amp;quot;More stuff&amp;quot;,&lt;br /&gt;
     3, &amp;quot;Some strings&amp;quot;,&lt;br /&gt;
     function() end}&lt;br /&gt;
&lt;br /&gt;
Another method is to use brackets, [ and ], to specify the key. This method requires the table to have already been created, using { and }, otherwise it will give you an error. Using this method will treat it as a regular variable, so you can both set and read the value with this method. This method is commonly used for getting a value when the key is a number.&lt;br /&gt;
 local Table = {}&lt;br /&gt;
 Table[&amp;quot;Boolean&amp;quot;] = true&lt;br /&gt;
 &lt;br /&gt;
 if Table[&amp;quot;Boolean&amp;quot;] then print(&amp;quot;The value is true!&amp;quot;) end&lt;br /&gt;
&lt;br /&gt;
If you need to reference a table within a table using this method, you can simply add another [ ]&lt;br /&gt;
&lt;br /&gt;
 local Table = {&amp;quot;Value&amp;quot;, 2, {true, false}}&lt;br /&gt;
 &lt;br /&gt;
 if Table[3][2] then print(&amp;quot;The value is true!&amp;quot;) else print(&amp;quot;The value is false!&amp;quot;) end&lt;br /&gt;
&lt;br /&gt;
A third method is to simply add the key onto the end of the table name, separated by a &amp;quot;.&amp;quot;. Like the previous method, this method requires the table to already exist. It can also be treated as a regular variable, as above. This method is commonly used for when the key is a string.&lt;br /&gt;
 local Table = {}&lt;br /&gt;
 &lt;br /&gt;
 Table.key = true&lt;br /&gt;
 if Table.key then print(&amp;quot;True!&amp;quot;) end&lt;br /&gt;
&lt;br /&gt;
As with the second method, to index a table within a table you just add the second key to the end. Note that these methods are interchangeable, and can all be used at the same time.&lt;br /&gt;
&lt;br /&gt;
It is not advisable to have many tables inside each other, especially if they are similarly named&lt;br /&gt;
 local Table = {String = &amp;quot;This is a string!&amp;quot;, Table = {Number = 2, Table = {func = write, Table = {Bool = true} } }}&lt;br /&gt;
 &lt;br /&gt;
 if Table[&amp;quot;Table&amp;quot;].Table.Table.Bool then print(&amp;quot;True!&amp;quot;) end&lt;br /&gt;
&lt;br /&gt;
If you don't mind being restricted to number keys, you could use the table.insert(Table, [Position,] Value ) function.&lt;br /&gt;
 local Table = {&amp;quot;One&amp;quot;}&lt;br /&gt;
 table.insert(Table, &amp;quot;Three&amp;quot;) --This inserts the string &amp;quot;Three&amp;quot; to the end of the table (At key 2)&lt;br /&gt;
 table.insert(Table, 2, &amp;quot;Two&amp;quot;) --This inserts the string &amp;quot;Two&amp;quot; to key 2, pushing the string &amp;quot;Three&amp;quot; up to key three&lt;br /&gt;
 --End result, Table[1] is One, Table[2] is Two, Table[3] is Three&lt;br /&gt;
&lt;br /&gt;
== Tables and Loops ==&lt;br /&gt;
&lt;br /&gt;
When you combine tables and loops, they suddenly become a lot more useful. You can run through a table easily, using or changing each value.&lt;br /&gt;
 local Table = {&amp;quot;Hello! &amp;quot;, &amp;quot;This string &amp;quot;, &amp;quot;was read from &amp;quot;, &amp;quot;a table!&amp;quot;, &amp;quot;\n&amp;quot;}&lt;br /&gt;
 for i=1,#Table do&lt;br /&gt;
    write( Table[i] )&lt;br /&gt;
 end&lt;br /&gt;
This will write &amp;quot;Hello! This string was read from a table!&amp;quot; followed by a new line. You may notice there's a &amp;quot;#&amp;quot; in front of Table, this simply returns the number of values in the table. It can also be used to get the length of a string.&lt;br /&gt;
&lt;br /&gt;
The standard for loop does, however, come with an inherent disadvantage in that it can only (easily) access consecutive numerical strings, ie 1,2,3 but not 1,2,4. to get around this, we can use &amp;quot;pairs&amp;quot; and &amp;quot;ipairs&amp;quot;. &amp;quot;pairs&amp;quot; and &amp;quot;ipairs&amp;quot; use a table to loop, by running through the keys and values for the number that exist in the table.&lt;br /&gt;
 local Table = {StartTime = 0.5, EndTime = 1.5}&lt;br /&gt;
 &lt;br /&gt;
 for key,value in pairs( Table ) do&lt;br /&gt;
    print(tostring(key)..&amp;quot;: &amp;quot;..tostring(value))&lt;br /&gt;
 end&lt;br /&gt;
This will output equivalent to &amp;quot;EndTime: 1.5: StartTime: 0.5&amp;quot;. Note that ipairs is identical to pairs, except it tries to do it in order.&lt;br /&gt;
&lt;br /&gt;
== Saving Tables to Files ==&lt;br /&gt;
&lt;br /&gt;
To save a table to file in ComputerCraft it must first be converted to a string using textutils.serialize (table.save is not included). Example function to save a table to a file:&lt;br /&gt;
&lt;br /&gt;
 function save(table,name)&lt;br /&gt;
 local file = fs.open(name,&amp;quot;w&amp;quot;)&lt;br /&gt;
 file.write(textutils.serialize(table))&lt;br /&gt;
 file.close()&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
To load, the string must be converted back to a table using textutils.unserialize. Example function to load a table from a file:&lt;br /&gt;
&lt;br /&gt;
 function load(name)&lt;br /&gt;
 local file = fs.open(name,&amp;quot;r&amp;quot;)&lt;br /&gt;
 local data = file.readAll()&lt;br /&gt;
 file.close()&lt;br /&gt;
 return textutils.unserialize(data)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== Using Tables as Matrices ==&lt;br /&gt;
&lt;br /&gt;
Tables can provide the functionality of matrices by &amp;quot;nesting&amp;quot; tables inside one another. Example function to make an M by N matrix:&lt;br /&gt;
&lt;br /&gt;
 function matrix(M,N)&lt;br /&gt;
 mt = {}&lt;br /&gt;
 for i=1,M do&lt;br /&gt;
   mt[i] = {}&lt;br /&gt;
   for j=1,N do&lt;br /&gt;
     mt[i][j] = 0&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Example of a serialized 3 by 4 matrix:&lt;br /&gt;
&lt;br /&gt;
 {[1]={[1]=0,[2]=0,[3]=0,},[2]={[1]=0,[2]=0,[3]=0,},[3]={[1]=0,[2]=0,[3]=0,},[4]={[1]=0,[2]=0,[3]=0,},}&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Fs.move&amp;diff=1943</id>
		<title>Fs.move</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Fs.move&amp;diff=1943"/>
				<updated>2012-07-04T02:36:38Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Undo revision 1932 by 91.121.27.33 (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{lowercase}}&lt;br /&gt;
{{Function&lt;br /&gt;
|name=fs.move&lt;br /&gt;
|args=[[string (type)|string]] fromPath, [[string (type)|string]] toPath&lt;br /&gt;
|api=fs&lt;br /&gt;
|desc=Moves a file or directory to a new location (the parent of the new location must be a directory, &amp;lt;var&amp;gt;toPath&amp;lt;/var&amp;gt; must include the target filename and cannot be only a directory to move the file into, and &amp;lt;var&amp;gt;toPath&amp;lt;/var&amp;gt; itself must not already exist)&lt;br /&gt;
|examples=&lt;br /&gt;
{{Example&lt;br /&gt;
|desc=Renames a file from &amp;quot;test1&amp;quot; to &amp;quot;test2&amp;quot; and moves it from the root directory into a directory called &amp;quot;mydir&amp;quot;&lt;br /&gt;
|code=fs.move(&amp;quot;test1&amp;quot;, &amp;quot;mydir/test2&amp;quot;)&lt;br /&gt;
}}&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Bit.blshift&amp;diff=1942</id>
		<title>Bit.blshift</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Bit.blshift&amp;diff=1942"/>
				<updated>2012-07-04T02:36:17Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Undo revision 1933 by 91.121.27.33 (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{lowercase}}&lt;br /&gt;
{{Function&lt;br /&gt;
|name=bit.blshift&lt;br /&gt;
|args=[[int (type)|int]] n, [[int (type)|int]] bits&lt;br /&gt;
|api=bit&lt;br /&gt;
|returns=[[int]] the value of &amp;lt;var&amp;gt;n&amp;lt;/var&amp;gt; shifted left by &amp;lt;var&amp;gt;bits&amp;lt;/var&amp;gt; bits, which is equivalent to &amp;lt;var&amp;gt;n&amp;lt;/var&amp;gt;×2&amp;lt;sup&amp;gt;&amp;lt;var&amp;gt;bits&amp;lt;/var&amp;gt;&amp;lt;/sup&amp;gt;&lt;br /&gt;
|addon=ComputerCraft&lt;br /&gt;
|desc=Shifts a number left by a specified number of bits&lt;br /&gt;
|examples=&lt;br /&gt;
{{Example&lt;br /&gt;
|desc=Shift the number 18 (10010) left by 2 bits, yielding 72 (1001000)&lt;br /&gt;
|code=print(bit.blshift(18, 2))&lt;br /&gt;
|output=72&lt;br /&gt;
}}&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Term.clearLine&amp;diff=1941</id>
		<title>Term.clearLine</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Term.clearLine&amp;diff=1941"/>
				<updated>2012-07-04T02:35:58Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Undo revision 1934 by 91.121.27.33 (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{lowercase}}&lt;br /&gt;
{{Function&lt;br /&gt;
|name=term.clearLine&lt;br /&gt;
|args=none&lt;br /&gt;
|returns=none&lt;br /&gt;
|api=term&lt;br /&gt;
|addon=ComputerCraft&lt;br /&gt;
|desc=Clears the line that the cursor is currently on.&lt;br /&gt;
|examples=&lt;br /&gt;
{{Example&lt;br /&gt;
|desc=Clears the line that the cursor is currently on.&lt;br /&gt;
|code=term.clearLine()&lt;br /&gt;
}}&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Advanced_Turtle_Lumberjack_(tutorial)&amp;diff=1939</id>
		<title>Advanced Turtle Lumberjack (tutorial)</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Advanced_Turtle_Lumberjack_(tutorial)&amp;diff=1939"/>
				<updated>2012-07-04T02:34:55Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Undo revision 1936 by 91.121.27.33 (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== Advanced Turtle Lumberjack ==&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
Welcome to this [[:Category:Tutorials|tutorial]] about Advanced Turtle Lumberjacks.&lt;br /&gt;
See the [[Turtle_Lumberjack_(tutorial)|Turtle Lumberjack Tutorial]] first.&lt;br /&gt;
&lt;br /&gt;
=== What are Advanced Turtle Lumberjacks? ===&lt;br /&gt;
Advanced Turtle Lumberjacks are basically [[Turtle_Lumberjack_(tutorial)|Turtle Lumberjacks]] that can dig blocks above them. We first make the turtle dig the block in front of it and then move forward so the rest of the tree is directly above it.&lt;br /&gt;
&lt;br /&gt;
== The Code ==&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
  turtle.dig()&lt;br /&gt;
  turtle.forward()&lt;br /&gt;
  while turtle.detectUp() do&lt;br /&gt;
    turtle.digUp()&lt;br /&gt;
    turtle.up()&lt;br /&gt;
  end&lt;br /&gt;
  while not turtle.detectDown() do&lt;br /&gt;
    turtle.down()&lt;br /&gt;
  end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
This makes us check if there are no blocks to be dug, then we go down until we can't.&lt;br /&gt;
That's it!&lt;br /&gt;
&lt;br /&gt;
-----------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
'''Another Advanced Turtle Lumberjack''' (Made By Freakout2114)&lt;br /&gt;
&lt;br /&gt;
This is a lot more complex BUT this can create a row of trees and constantly monitor them to see if they have grown or not. Here is a link to a video showing what it does- [http://www.youtube.com/watch?v=7rmB09b6wYk ComputerCraft-Turtle-Tree Lumberjack]&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 shell.run('clear')&lt;br /&gt;
 C=1&lt;br /&gt;
 X=0&lt;br /&gt;
 X1=0&lt;br /&gt;
 print(&amp;quot;Place Dirt in Slot 1 and Saplings in Slot 2 and 1 log in slot 3 Thankyou :) &amp;quot;)&lt;br /&gt;
 write(&amp;quot;How many trees do you want me to plant X direction?:&amp;quot;)&lt;br /&gt;
 X=io.read()&lt;br /&gt;
 &lt;br /&gt;
 X=X+0&lt;br /&gt;
 X1=X&lt;br /&gt;
 X1=X1+0&lt;br /&gt;
 &lt;br /&gt;
 turtle.up()&lt;br /&gt;
 turtle.turnLeft()&lt;br /&gt;
 turtle.turnLeft()&lt;br /&gt;
 &lt;br /&gt;
 turtle.back()&lt;br /&gt;
 turtle.back()&lt;br /&gt;
 turtle.back()&lt;br /&gt;
 &lt;br /&gt;
 while C&amp;gt;0 do&lt;br /&gt;
 	while X&amp;gt;0 do&lt;br /&gt;
 	turtle.digDown()&lt;br /&gt;
 	turtle.select(1)&lt;br /&gt;
 	turtle.placeDown()&lt;br /&gt;
 	turtle.back()&lt;br /&gt;
 	turtle.select(2)&lt;br /&gt;
 	turtle.place()&lt;br /&gt;
 	turtle.back()&lt;br /&gt;
 	turtle.back()&lt;br /&gt;
 	turtle.back()&lt;br /&gt;
 	X=X-1&lt;br /&gt;
 	end&lt;br /&gt;
 C=0&lt;br /&gt;
 end	&lt;br /&gt;
 print(&amp;quot;Planted Trees!&amp;quot;)&lt;br /&gt;
  &lt;br /&gt;
 turtle.turnLeft()&lt;br /&gt;
 turtle.forward()&lt;br /&gt;
 turtle.turnRight()&lt;br /&gt;
  &lt;br /&gt;
   &lt;br /&gt;
  &lt;br /&gt;
 --/chop trees&lt;br /&gt;
 X=X1&lt;br /&gt;
 C=1&lt;br /&gt;
 C=C+0&lt;br /&gt;
 while C&amp;gt;0 do&lt;br /&gt;
 while X&amp;gt;0 do&lt;br /&gt;
 print(&amp;quot;X= &amp;quot;..X..&amp;quot;&amp;quot;)&lt;br /&gt;
 X=X+0&lt;br /&gt;
 	turtle.forward()&lt;br /&gt;
 	turtle.forward()&lt;br /&gt;
 	turtle.forward()&lt;br /&gt;
 	turtle.forward()&lt;br /&gt;
 	turtle.turnRight()&lt;br /&gt;
 	turtle.select(3)&lt;br /&gt;
 		if turtle.compare()==true then&lt;br /&gt;
 		turtle.dig()&lt;br /&gt;
 		turtle.forward()&lt;br /&gt;
 		&lt;br /&gt;
 			while turtle.detectUp() do&lt;br /&gt;
 			turtle.up()&lt;br /&gt;
 			turtle.digUp()&lt;br /&gt;
 			turtle.up()&lt;br /&gt;
 			end&lt;br /&gt;
 			&lt;br /&gt;
 			while turtle.detectDown()==false do&lt;br /&gt;
 			turtle.down()&lt;br /&gt;
 			end&lt;br /&gt;
 		turtle.back()&lt;br /&gt;
 		turtle.select(2)&lt;br /&gt;
 		turtle.place()&lt;br /&gt;
 		end&lt;br /&gt;
 	&lt;br /&gt;
 	turtle.turnLeft()&lt;br /&gt;
 X=X-1&lt;br /&gt;
 print(&amp;quot;X after = &amp;quot;..X..&amp;quot;&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
 turtle.forward()&lt;br /&gt;
 turtle.turnRight()&lt;br /&gt;
 turtle.forward()&lt;br /&gt;
 turtle.forward()&lt;br /&gt;
 turtle.turnRight()&lt;br /&gt;
 turtle.forward()&lt;br /&gt;
 X=X1&lt;br /&gt;
 W=turtle.getItemCount(3)&lt;br /&gt;
 print(&amp;quot;I've cut down &amp;quot;..T..&amp;quot; Trees&amp;quot;)&lt;br /&gt;
 print(&amp;quot;I've collected &amp;quot;..W..&amp;quot; Logs&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
('''Helpful tip:''' Save this to your computercraft/lua/rom/programs folder, then it will be on all turtles.)&lt;br /&gt;
&lt;br /&gt;
== Category &amp;amp; Author ==&lt;br /&gt;
A tutorial by [[User:TheVarmari|TheVarmari]]. Feel free to correct any mistakes!&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Talk:Default_commands&amp;diff=1894</id>
		<title>Talk:Default commands</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Talk:Default_commands&amp;diff=1894"/>
				<updated>2012-06-29T08:16:26Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Created page with &amp;quot;What is this page? Why is it so badly written? How is it different from :Category:APIs? Removing it in favour of a redirect unless someone can both give a good reason for ...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;What is this page? Why is it so badly written? How is it different from [[:Category:APIs]]? Removing it in favour of a redirect unless someone can both give a good reason for it to be separate, and write a page that actually makes sense. [[User:My hat stinks|my_hat_stinks]] 08:16, 29 June 2012 (UTC)&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Turtle&amp;diff=1893</id>
		<title>Turtle</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Turtle&amp;diff=1893"/>
				<updated>2012-06-29T08:11:39Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Turtles''' are essentially robots, and were added in the 1.3 update. They run an OS (like the [[Console|consoles]]) named [[TurtleOS]]. They have the ability to place, break and detect blocks, move around and drop items in their inventory. The programs they run are stored on [[Floppy Disk|floppy disks]].&lt;br /&gt;
&lt;br /&gt;
Turtles are submersible and lavaproof. As such, they are extremely useful for mining near bedrock, where heavy lava flows can prevent access to diamonds and other rare finds.&lt;br /&gt;
&lt;br /&gt;
If you would like to know more about how to program them, have a look at the [[Turtle (API)|Turtle API]].&lt;br /&gt;
&lt;br /&gt;
==Floppy Disks==&lt;br /&gt;
Turtles do not have a built-in floppy drive. As such they need a floppy drive placed next to them to access disks.&lt;br /&gt;
&lt;br /&gt;
==Power source==&lt;br /&gt;
Turtles have been equipped with a state of the art AWESOME FANTASTIC AMAZING quantum ionizing engine. This means that, once given fuel (the redstone used to craft them), they do not need to be re-charged, nor do any fuel cells need to be replaced, likewise they don't need to have external power directed to them either.&lt;br /&gt;
&lt;br /&gt;
==Mining==&lt;br /&gt;
Turtles crafted with a [[diamond pickaxe]] can break blocks. Mining turtle's pickaxes have no durability, and so can be used indefinitely without the need for any additional materials. When a mining turtle breaks a block, the mined block will be placed directly into it's inventory.&lt;br /&gt;
&lt;br /&gt;
==Crafting==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|+'''Crafting ingredients'''&lt;br /&gt;
|-&lt;br /&gt;
|Turtle&lt;br /&gt;
|{{Crafting grid&lt;br /&gt;
 |A1=iron_ingot |B1=iron_ingot |C1=iron_ingot&lt;br /&gt;
 |A2=iron_ingot |B2=console    |C2=iron_ingot&lt;br /&gt;
 |A3=iron_ingot |B3=chest      |C3=iron_ingot&lt;br /&gt;
 |Output=turtle&lt;br /&gt;
 }}&lt;br /&gt;
|-&lt;br /&gt;
|Mining Turtle&lt;br /&gt;
|{{Crafting grid&lt;br /&gt;
 |A2=turtle |B2=diamond_pickaxe&lt;br /&gt;
 |Output=mining_turtle&lt;br /&gt;
 }}&lt;br /&gt;
|-&lt;br /&gt;
|Wireless Turtle&lt;br /&gt;
|{{Crafting grid&lt;br /&gt;
 |A2=turtle |B2=modem&lt;br /&gt;
 |Output=wireless_turtle&lt;br /&gt;
 }}&lt;br /&gt;
|-&lt;br /&gt;
|Wireless Mining Turtle&lt;br /&gt;
|{{Crafting grid&lt;br /&gt;
 |A1=modem |B1=turtle |C1=diamond_pickaxe&lt;br /&gt;
 |Output=wireless_mining_turtle&lt;br /&gt;
 }}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Blocks]]&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Redstone&amp;diff=1848</id>
		<title>Redstone</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Redstone&amp;diff=1848"/>
				<updated>2012-06-25T01:06:16Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Undo revision 1812 by Wukl (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Redstone_(API)]]&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=CCGPU&amp;diff=1847</id>
		<title>CCGPU</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=CCGPU&amp;diff=1847"/>
				<updated>2012-06-25T01:03:26Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Undo revision 1811 by 37.59.80.67 (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The CCGPU peripheral is an addon for [[ComputerCraft]] which allows you to do [http://en.wikipedia.org/wiki/OpenGL OpenGL] operations within computercraft using [http://www.lua.org/ Lua].&lt;br /&gt;
The peripheral currently comes with two elements: a [[#GPU]] peripheral and a [[#Monitor]] output device.&lt;br /&gt;
&lt;br /&gt;
== GPU ==&lt;br /&gt;
A GPU can be attached to a [[Computer]] on all sides except for the bottom.&lt;br /&gt;
The GPU peripheral comes with it's own [[API]] featuring extra methods that cannot be accessed using [[Peripheral_(API)|peripheral.wrap]].&lt;br /&gt;
&lt;br /&gt;
You can find the GPU api over [[GPU_(API)|here]]&lt;br /&gt;
&lt;br /&gt;
== Graphics Devices ==&lt;br /&gt;
A graphics device operates on a certain frequency (corresponding to a [[#GPU]]'s id) and has an id indicating which buffer it is bound to.&lt;br /&gt;
All graphics devices have a certain resolution corresponding to the resolution of the graphics they can handle.&lt;br /&gt;
&lt;br /&gt;
=== Graphics Output Devices ===&lt;br /&gt;
Output devices are used to display a certain output buffer to the user.&lt;br /&gt;
&lt;br /&gt;
==== Monitor ====&lt;br /&gt;
The Monitor block can be placed facing up to 4 directions and &lt;br /&gt;
&lt;br /&gt;
=== Graphics Input Devices ===&lt;br /&gt;
Currently CCGPU doesn't have any default input devices.&lt;br /&gt;
A camera might be added in the future.&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=CCGPU&amp;diff=1846</id>
		<title>CCGPU</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=CCGPU&amp;diff=1846"/>
				<updated>2012-06-25T01:02:50Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Undo revision 1813 by Wukl (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hello my friend heres my new gig easy as it looks Ill send u a total of 5350++ backlinks to your website in 2 tiers. This gig its for 1 website and up to 5 keywords. First tier to your main website 350 page rank 1-5 and the the second tier of 5000 profile backlinks pointing to your first tier.Ill send u a report in a txt file in less than 48 hours.Any question just send me a private message&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Making_a_Password_Protected_Door&amp;diff=1769</id>
		<title>Making a Password Protected Door</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Making_a_Password_Protected_Door&amp;diff=1769"/>
				<updated>2012-06-14T18:51:22Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Undo revision 1768 by 173.170.254.124 (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
This tutorial covers on how to make a computer output redstone current when the right password is typed in. The current is then used to trigger an iron door.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
= How to make it =&lt;br /&gt;
&lt;br /&gt;
A password protected door is actually pretty easy, if you break it into steps.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First, you need to craft a computer, and connect the back to an iron door with redstone. Like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Tutorial1.png]]&lt;br /&gt;
&lt;br /&gt;
[[File:cTutorial2.png]]&lt;br /&gt;
&lt;br /&gt;
Once you're done with the basics, open the computer and edit the &amp;quot;startup&amp;quot; file. (type in 'edit startup')&lt;br /&gt;
This will make it so the program will be executed when the computer boots.&lt;br /&gt;
&lt;br /&gt;
Once you access the startup file, enter in these two lines.&lt;br /&gt;
&lt;br /&gt;
[[File:CTutorial3.png]]&lt;br /&gt;
&lt;br /&gt;
(alternatively, if you don't want people looking at your password, E.G in a server, type this code ( instead of 't = io.read()' ): t = read(&amp;quot;*&amp;quot;) , that will * out the password)&lt;br /&gt;
The first line defines a function, so that we can repeat the program if a password is entered,&lt;br /&gt;
and the second line is assigning whatever the user types to the variable, &amp;quot;t&amp;quot;,&lt;br /&gt;
So for example, if I typed &amp;quot;qwerty&amp;quot;, it would be t = &amp;quot;qwerty&amp;quot;. It also overrides anything else the user types in,&lt;br /&gt;
so if I typed in &amp;quot;programs&amp;quot;, it would just be t = &amp;quot;programs&amp;quot;, and not act as the programs command in the regular&lt;br /&gt;
OS. This can very useful.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After you're done with the previous lines, enter in the following line:&lt;br /&gt;
&lt;br /&gt;
[[File:CTutorial4.png]]&lt;br /&gt;
&lt;br /&gt;
This makes it so the program checks if the variable that we declared earlier, &amp;quot;t&amp;quot;, equals &amp;quot;password&amp;quot;. (You can change password to what you want the actual password to be.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
But now you'll need to put in what to do, depending on if the user typed in the right password.&lt;br /&gt;
This next set of lines will do that:&lt;br /&gt;
&lt;br /&gt;
[[File:CTutorial5.png]]&lt;br /&gt;
&lt;br /&gt;
Now, this may seem complicated, but it's really simple. The four lines after the if line, determine what the computer will do if the password is correct. So if it's correct, It'll set the redstone output from it's back to true (on), and open the door. (this is the &amp;quot;redstone.setOutput(&amp;quot;back&amp;quot;, true)&amp;quot; command.) It'll then wait two seconds, and turn the redstone back off again. It'll then repeat the function, so you don't need to reboot the computer.&lt;br /&gt;
&lt;br /&gt;
However, the last two lines dictate what the computer will do if the password is wrong, which is really just not opening the door, and repeating the function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And now the finishing touches:&lt;br /&gt;
&lt;br /&gt;
[[File:CTutorial6.png]]&lt;br /&gt;
&lt;br /&gt;
This adds the &amp;quot;Ends&amp;quot; to the if which is inside the function, and the function. So we've declared our function.&lt;br /&gt;
Now to start it, we have the computer call the function after it declares it.&lt;br /&gt;
&lt;br /&gt;
Well, you should have your own password protected door!&lt;br /&gt;
Feel free to change the script around, maybe add a few success/failure messages, etc, etc.&lt;br /&gt;
&lt;br /&gt;
(NOTE: If the program fails somehow, Pressing and holding Ctrl + T will terminate it, and allow you to edit it like normally, see the [http://computercraft.info/wiki/index.php?title=Making_a_Password_Protected_Door#Stop_people_from_terminating_your_lock No termination section] to stop people from exiting your lock, if someone exits your lock, they could edit your lock file, and finding out your password, now you don't want that!)&lt;br /&gt;
&lt;br /&gt;
= Alternative / Better code =&lt;br /&gt;
&lt;br /&gt;
Heres a pastebin.com address --&amp;gt;  http://pastebin.com/bACeVS2Q&lt;br /&gt;
&lt;br /&gt;
Type 'edit startup' and type in this code: &lt;br /&gt;
(Use Ctrl + T to terminate the program, all code is explained in the comments, the --'s. It's good to read the comments, so you actually know what the code does, you do not need to have the comments in your code, of course)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
local side = &amp;quot;left&amp;quot; -- Change left to whatever side your door / redstone is on, E.G: left, right, front, back, bottom, top. Be sure to leave the &amp;quot;s around it, though&lt;br /&gt;
local password = &amp;quot;bacon&amp;quot; -- Change bacon to what you want your password to be. Be sure to leave the &amp;quot;s around it, though&lt;br /&gt;
local opentime = 5 -- Change 5 to how long (in seconds) you want the redstone current to be on. Don't put &amp;quot;s around it, though&lt;br /&gt;
term.clear() -- Clears the screen&lt;br /&gt;
term.setCursorPos(1,1) -- Fixes the cursor position&lt;br /&gt;
write(&amp;quot;Password: &amp;quot;) -- Prints 'Password: ' to the screen&lt;br /&gt;
local input = read(&amp;quot;*&amp;quot;) -- Makes the variable 'input' have the contents of what the user types in, the &amp;quot;*&amp;quot; part sensors out the password&lt;br /&gt;
if input == (password) then -- Checks if the user inputted the correct password&lt;br /&gt;
 term.clear() -- Already explained up top&lt;br /&gt;
 term.setCursorPos(1,1)&lt;br /&gt;
 print(&amp;quot;Password correct!&amp;quot;) -- Prints 'Password correct!' to the screen&lt;br /&gt;
 rs.setOutput(side,true) -- Output a redstone current to the side you specified&lt;br /&gt;
 sleep(opentime) -- Wait the amount of seconds you specifed, then..&lt;br /&gt;
 rs.setOutput(side,false) -- Stop outputting a redstone current&lt;br /&gt;
 os.reboot() -- Reboot the computer, reopening the lock&lt;br /&gt;
else -- Checks if the user didn't input the correct password&lt;br /&gt;
 term.clear()&lt;br /&gt;
 term.setCursorPos(1,1)&lt;br /&gt;
 print(&amp;quot;Password incorrect!&amp;quot;) -- Prints 'Password incorrect!' to the screen&lt;br /&gt;
 sleep(2) -- Waits 2 seconds&lt;br /&gt;
 os.reboot() -- Reboot the computer, reopening the lock&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Stop people from terminating your lock =&lt;br /&gt;
&lt;br /&gt;
If you don't want people holding CTRL+T and quitting your lock, use this code at the top of your program:&lt;br /&gt;
&amp;lt;pre&amp;gt;os.pullEvent = os.pullEventRaw&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Adventure&amp;diff=1749</id>
		<title>Adventure</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Adventure&amp;diff=1749"/>
				<updated>2012-06-10T15:23:15Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Undo revision 1747 by 74.85.197.6 (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[image:2012-01-30 22.51.59.png|frame|right|Gameplay of Adventure.]]Adventure is one of the default programs. Adventure emulates a text adventure, but it takes place in MineCraft. Most LPs consist of LPers playing Adventure. Therefore, it is possible to play MineCraft, on a computer, in MineCraft, on a computer. This is referred to by the internet as &amp;quot;recursion&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
for more ingame info type: &amp;quot;help&amp;quot;&lt;br /&gt;
[[Category:Notable Programs]]&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Talk:Redstone.getInput&amp;diff=1748</id>
		<title>Talk:Redstone.getInput</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Talk:Redstone.getInput&amp;diff=1748"/>
				<updated>2012-06-10T15:07:00Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;It doesn't show what a string is!!!&lt;br /&gt;
:Sign your comments. It doesn't need to tell you what a string is, because that's very basic coding for ''any'' language. See [[Variables]]. [[User:My hat stinks|my_hat_stinks]]&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Tables&amp;diff=1741</id>
		<title>Tables</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Tables&amp;diff=1741"/>
				<updated>2012-06-05T16:08:14Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: /* Tables and Loops */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Tutorials]]&lt;br /&gt;
This script will introduce you to tables, and show you some ways to use them.&lt;br /&gt;
If you have experience with other languages, a table is roughly equivalent to an array.&lt;br /&gt;
&lt;br /&gt;
== Why are tables useful? ==&lt;br /&gt;
&lt;br /&gt;
Tables can simplify code considerably, by grouping like variables and functions together.&lt;br /&gt;
&lt;br /&gt;
In this example, we're getting a list of student's names&lt;br /&gt;
Code without tables&lt;br /&gt;
 local StudentName1 = &amp;quot;Andrew&amp;quot;&lt;br /&gt;
 local StudentName2 = &amp;quot;Alfred&amp;quot;&lt;br /&gt;
 local StudentName3 = &amp;quot;Alex&amp;quot;&lt;br /&gt;
 local StudentName4 = &amp;quot;Amber&amp;quot;&lt;br /&gt;
 local StudentName5 = &amp;quot;Alice&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Code with tables&lt;br /&gt;
 local StudentNames = {&amp;quot;Andrew&amp;quot;, &amp;quot;Alfred&amp;quot;, &amp;quot;Alex&amp;quot;, &amp;quot;Amber&amp;quot;, &amp;quot;Alice&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
As you can see, the first example needs 5 unique variables being defined individually, while the second example, using the table, is all one line with one variable.&lt;br /&gt;
&lt;br /&gt;
Note the { and }, this is how you spot a table. Anything between them is a variable to be stored in the table. A table is not restricted to one variable type, and you can even store tables within tables if you wish&lt;br /&gt;
&lt;br /&gt;
== Using the table ==&lt;br /&gt;
&lt;br /&gt;
There are a number of ways to set the values in a table. The first, as shown above, is the simplest method, and will give each value a unique number as the &amp;quot;key&amp;quot;. The key is simply the location in the table, it's usually a number or string. This method always clears the contents of the table and replaces it with what you've specified. Note that setting a table to &amp;quot;{}&amp;quot; is valid, and is commonly used if the values don't need to, or can't, be set immediately. You may find yourself using &amp;quot;Variable={}&amp;quot; often. Setting a specific key with this method is relatively simple, you just use the asignment operator &amp;quot;=&amp;quot; and treat the key as a variable&lt;br /&gt;
 local Table = {Key1 = &amp;quot;First key!&amp;quot;, Key2 = &amp;quot;Second key!&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
It can also be defined over multiple lines, to help with readability, if you end the line with a comma rather than the } to close it. Just remember to add the } when you're done.&lt;br /&gt;
 local Table = {&amp;quot;Stuff&amp;quot;, 1, 2, &amp;quot;More stuff&amp;quot;,&lt;br /&gt;
     3, &amp;quot;Some strings&amp;quot;,&lt;br /&gt;
     function() end}&lt;br /&gt;
&lt;br /&gt;
Another method is to use the square parenthesis [ and ] to specify the key. This method requires the table to have already been created, using { and }, otherwise it will give you an error. Using this method will treat it as a regular variable, so you can both set and read the value with this method. This method is commonly used for getting a value when the key is a number.&lt;br /&gt;
 local Table = {}&lt;br /&gt;
 Table[&amp;quot;Boolean&amp;quot;] = true&lt;br /&gt;
 &lt;br /&gt;
 if Table[&amp;quot;Boolean&amp;quot;] then print(&amp;quot;The value is true!&amp;quot;) end&lt;br /&gt;
&lt;br /&gt;
If you need to reference a table within a table using this method, you can simply add another [ ]&lt;br /&gt;
&lt;br /&gt;
 local Table = {&amp;quot;Value&amp;quot;, 2, {true, false}}&lt;br /&gt;
 &lt;br /&gt;
 if Table[3][2] then print(&amp;quot;The value is true!&amp;quot;) else print(&amp;quot;The value is false!&amp;quot;) end&lt;br /&gt;
&lt;br /&gt;
A third method is to simply add the key onto the end of the table name, separated by a &amp;quot;.&amp;quot;. Like the previous method, this method requires the table to already exist. It can also be treated as a regular variable, as above. This method is commonly used for when the key is a string.&lt;br /&gt;
 local Table = {}&lt;br /&gt;
 &lt;br /&gt;
 Table.key = true&lt;br /&gt;
 if Table.key then print(&amp;quot;True!&amp;quot;) end&lt;br /&gt;
&lt;br /&gt;
As with the second method, to index a table within a table you just add the second key to the end. Note that these methods are interchangeable, and can all be used at the same time.&lt;br /&gt;
&lt;br /&gt;
It is not advisable to have many tables inside each other, especially if they are similarly named&lt;br /&gt;
 local Table = {String = &amp;quot;This is a string!&amp;quot;, Table = {Number = 2, Table = {func = write, Table = {Bool = true} } }}&lt;br /&gt;
 &lt;br /&gt;
 if Table[Table].Table.Table.Bool then print(&amp;quot;True!&amp;quot;) end&lt;br /&gt;
&lt;br /&gt;
If you don't mind being restricted to number keys, you could use the table.insert(Table, [Position,] Value ) function.&lt;br /&gt;
 local Table = {&amp;quot;One&amp;quot;}&lt;br /&gt;
 table.insert(Table, &amp;quot;Three&amp;quot;) --This inserts the string &amp;quot;Three&amp;quot; to the end of the table (At key 2)&lt;br /&gt;
 table.insert(Table, 2, &amp;quot;Two&amp;quot;) --This inserts the string &amp;quot;Two&amp;quot; to key 2, pushing the string &amp;quot;Three&amp;quot; up to key three&lt;br /&gt;
 --End result, Table[1] is One, Table[2] is Two, Table[3] is Three&lt;br /&gt;
&lt;br /&gt;
== Tables and Loops ==&lt;br /&gt;
&lt;br /&gt;
When you combine tables and loops, they suddenly become a lot more useful. You can run through a table easily, using or changing each value.&lt;br /&gt;
 local Table = {&amp;quot;Hello! &amp;quot;, &amp;quot;This string &amp;quot;, &amp;quot;was read from &amp;quot;, &amp;quot;a table!&amp;quot;, &amp;quot;\n&amp;quot;}&lt;br /&gt;
 for i=1,#Table do&lt;br /&gt;
    write( Table[i] )&lt;br /&gt;
 end&lt;br /&gt;
This will write &amp;quot;Hello! This string was read from a table!&amp;quot; followed by a new line. You may notice there's a &amp;quot;#&amp;quot; behind Table, this simply returns the number of values in the table. It can also be used to get the length of a string.&lt;br /&gt;
&lt;br /&gt;
The standard for loop does, however, come with an inherent disadvantage in that it can only (easily) access consecutive numerical strings, ie 1,2,3 but not 1,2,4. to get around this, we can use &amp;quot;pairs&amp;quot; and &amp;quot;ipairs&amp;quot;. &amp;quot;pairs&amp;quot; and &amp;quot;ipairs&amp;quot; use a table to loop, by running through the keys and values for the number that exist in the table.&lt;br /&gt;
 local Table = {StartTime = 0.5, EndTime = 1.5}&lt;br /&gt;
 &lt;br /&gt;
 for key,value in pairs( Table ) do&lt;br /&gt;
    print( tostring(key) ..&amp;quot;: &amp;quot;..tostring(value))&lt;br /&gt;
 end&lt;br /&gt;
This will output equivalent to &amp;quot;EndTime: 1.5\nStartTime: 0.5&amp;quot;. Note that ipairs is identical to pairs, except it tries to do it in order.&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Loops&amp;diff=1738</id>
		<title>Loops</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Loops&amp;diff=1738"/>
				<updated>2012-06-03T16:43:34Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Tutorials]]&lt;br /&gt;
This is a tutorial page for loops and their application.&lt;br /&gt;
&lt;br /&gt;
== Introducing Loops ==&lt;br /&gt;
&lt;br /&gt;
At some point while coding, you will most likely want to run some code multiple times, without writing out a lot of code. While it is true that functions can shorten your code, there may be situations where even thouse don't simplify it enough. That's where loops come in.&lt;br /&gt;
&lt;br /&gt;
Here is a script without loops&lt;br /&gt;
 local function GetName()&lt;br /&gt;
    write(&amp;quot;Enter a name: &amp;quot;)&lt;br /&gt;
    return read()&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local Name1 = GetName()&lt;br /&gt;
 local Name2 = GetName()&lt;br /&gt;
 local Name3 = GetName()&lt;br /&gt;
 local Name4 = GetName()&lt;br /&gt;
 local Name5 = GetName()&lt;br /&gt;
 &lt;br /&gt;
 write(&amp;quot;You have entered &amp;quot;..Name1..&amp;quot; &amp;quot;..Name2..&amp;quot; &amp;quot;..Name3..&amp;quot; &amp;quot;..Name4..&amp;quot; &amp;quot;..Name5)&lt;br /&gt;
&lt;br /&gt;
As you can see, there is quite a lot of repetition, even when we're using a function.&lt;br /&gt;
&lt;br /&gt;
== The For loop ==&lt;br /&gt;
&lt;br /&gt;
The for loop is the most basic loop. It is in the following format&lt;br /&gt;
 for Variable = Start, End, Interval do&lt;br /&gt;
    --Insert code here&lt;br /&gt;
 end&lt;br /&gt;
Variable is a number that will track where we are in the loop. It is usually called &amp;quot;i&amp;quot;, or something more appropriate to the script. Start is a number to indicate the start point for the loop. This is generally 1, so the loop can count up easily. End is the number the loop will count to. Interval is an optional argument, and will specify how big the jumps would be . Ie, it specifies how much to add or subtract from Variable every loop.&lt;br /&gt;
&lt;br /&gt;
The best way to discover how the for loop works is to try it yourself. Try changing the numbers the following code to see how it reacts.&lt;br /&gt;
 for i=1,10 do&lt;br /&gt;
    print( &amp;quot;i is &amp;quot;..tostring(i) )&lt;br /&gt;
 end&lt;br /&gt;
Notice how it always counts up until Variable is the same or greater than End. Start, End, and Interval can also be variables, so it can loop a different number of times&lt;br /&gt;
 write(&amp;quot;How many times should I loop? &amp;quot;)&lt;br /&gt;
 local Num = tostring( read() )&lt;br /&gt;
 for i=1,Num do&lt;br /&gt;
    print(&amp;quot;Looped &amp;quot;..tostring(i)..&amp;quot; time(s).&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To simplify the first script using a for loop, it would look something like this:&lt;br /&gt;
 local string = &amp;quot;&amp;quot;&lt;br /&gt;
 for i=1,5 do&lt;br /&gt;
   write(&amp;quot;Enter a name: &amp;quot;)&lt;br /&gt;
   string=string..&amp;quot; &amp;quot;..read()&lt;br /&gt;
 end&lt;br /&gt;
 write(&amp;quot;You have entered &amp;quot;..string)&lt;br /&gt;
&lt;br /&gt;
== The While loop ==&lt;br /&gt;
&lt;br /&gt;
The While loop will continue looping until a certain condition is met.&lt;br /&gt;
 local Answer, Correct = &amp;quot;&amp;quot;, &amp;quot;2&amp;quot;&lt;br /&gt;
 while Answer~=Correct do&lt;br /&gt;
    write(&amp;quot;What is the sum of 1 and 1 (1+1)? &amp;quot;)&lt;br /&gt;
    Answer = read()&lt;br /&gt;
    &lt;br /&gt;
    if Answer == Correct then print(&amp;quot;Correct!&amp;quot;) else print(&amp;quot;Incorrect!&amp;quot;) end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
This type of loop is useful for if you don't want to specify a definite end for the loop. Although infinite loops are ill-advised, you may want to use one at some point.&lt;br /&gt;
 while true do --Always loop&lt;br /&gt;
    --Code here&lt;br /&gt;
 end&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Raw_key_events&amp;diff=1737</id>
		<title>Raw key events</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Raw_key_events&amp;diff=1737"/>
				<updated>2012-06-03T16:32:43Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: The original author is already credited in the page history&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The built-in os has a function to read incoming keystrokes. But it also implements the functions to move the cursor while typing. This is not always a desired feature; imagine a case in which you want to make a menu with a controllable cursor around the menu entries. The current read() function won't let you.&lt;br /&gt;
&lt;br /&gt;
==Detecting keystrokes==&lt;br /&gt;
In case I made you think the os sucks, it doesn't (all the time). Because this os is not Windows, we can access lower-level functions, such as os.pullEvent(). And that's the one that we're going to use:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function rawread()&lt;br /&gt;
    bRead = true&lt;br /&gt;
    while(bRead) do&lt;br /&gt;
        local sEvent, param = os.pullEvent(&amp;quot;key&amp;quot;)&lt;br /&gt;
        if(sEvent == &amp;quot;key&amp;quot;) then&lt;br /&gt;
            break&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This function waits for any key, then exits.&lt;br /&gt;
&lt;br /&gt;
==Figuring out the key==&lt;br /&gt;
We can detect any key, but not which key. To find it out, we have to add some further logic to the code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function rawread()&lt;br /&gt;
    bRead = true&lt;br /&gt;
    while(bRead) do&lt;br /&gt;
        local sEvent, param = os.pullEvent(&amp;quot;key&amp;quot;)&lt;br /&gt;
        if(sEvent == &amp;quot;key&amp;quot;) then&lt;br /&gt;
            if(param == 28) then&lt;br /&gt;
                print(&amp;quot;Enter detected&amp;quot;)&lt;br /&gt;
                break&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This function waits for the Enter key to be pressed. If so, it writes &amp;quot;Enter detected&amp;quot; to the screen and exits.&lt;br /&gt;
&lt;br /&gt;
However, this is only good for checking single keys. Also, what if you don't really want to look up the scan code on this page every time you code?&lt;br /&gt;
Fortunately there is a solution: the [[Raw key events/keymapper|keymapper API]]. See page for details.&lt;br /&gt;
&lt;br /&gt;
==Key scan codes ==&lt;br /&gt;
The scan codes are typical DirectX numbers.&lt;br /&gt;
{|&lt;br /&gt;
|style=&amp;quot;vertical-align: top&amp;quot;|&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! |Key&lt;br /&gt;
! |Code&lt;br /&gt;
|-&lt;br /&gt;
| Escape&lt;br /&gt;
| 1&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| 2&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| 3&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| 4&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| 6&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| 8&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| 10&lt;br /&gt;
|-&lt;br /&gt;
| 0&lt;br /&gt;
| 11&lt;br /&gt;
|-&lt;br /&gt;
| Minus&lt;br /&gt;
| 12&lt;br /&gt;
|-&lt;br /&gt;
| Equals&lt;br /&gt;
| 13&lt;br /&gt;
|-&lt;br /&gt;
| Backspace&lt;br /&gt;
| 14&lt;br /&gt;
|-&lt;br /&gt;
| Tab&lt;br /&gt;
| 15&lt;br /&gt;
|-&lt;br /&gt;
| Q&lt;br /&gt;
| 16&lt;br /&gt;
|-&lt;br /&gt;
| W&lt;br /&gt;
| 17&lt;br /&gt;
|-&lt;br /&gt;
| E&lt;br /&gt;
| 18&lt;br /&gt;
|-&lt;br /&gt;
| R&lt;br /&gt;
| 19&lt;br /&gt;
|-&lt;br /&gt;
| T&lt;br /&gt;
| 20&lt;br /&gt;
|-&lt;br /&gt;
| Y&lt;br /&gt;
| 21&lt;br /&gt;
|-&lt;br /&gt;
| U&lt;br /&gt;
| 22&lt;br /&gt;
|-&lt;br /&gt;
| I&lt;br /&gt;
| 23&lt;br /&gt;
|-&lt;br /&gt;
| O&lt;br /&gt;
| 24&lt;br /&gt;
|-&lt;br /&gt;
| P&lt;br /&gt;
| 25&lt;br /&gt;
|}&lt;br /&gt;
|style=&amp;quot;vertical-align: top&amp;quot;|&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! |Key&lt;br /&gt;
! |Code&lt;br /&gt;
|-&lt;br /&gt;
| Left Bracket&lt;br /&gt;
| 26&lt;br /&gt;
|-&lt;br /&gt;
| Right Bracket&lt;br /&gt;
| 27&lt;br /&gt;
|-&lt;br /&gt;
| Enter&lt;br /&gt;
| 28&lt;br /&gt;
|-&lt;br /&gt;
| Left Control&lt;br /&gt;
| 29&lt;br /&gt;
|-&lt;br /&gt;
| A&lt;br /&gt;
| 30&lt;br /&gt;
|- &lt;br /&gt;
| S&lt;br /&gt;
| 31&lt;br /&gt;
|-&lt;br /&gt;
| D&lt;br /&gt;
| 32&lt;br /&gt;
|-&lt;br /&gt;
| F&lt;br /&gt;
| 33&lt;br /&gt;
|-&lt;br /&gt;
| G&lt;br /&gt;
| 34&lt;br /&gt;
|-&lt;br /&gt;
| H&lt;br /&gt;
| 35&lt;br /&gt;
|-&lt;br /&gt;
| J&lt;br /&gt;
| 36&lt;br /&gt;
|-&lt;br /&gt;
| K&lt;br /&gt;
| 37&lt;br /&gt;
|-&lt;br /&gt;
| L&lt;br /&gt;
| 38&lt;br /&gt;
|-&lt;br /&gt;
| Semicolon&lt;br /&gt;
| 39&lt;br /&gt;
|-&lt;br /&gt;
| Apostrophe&lt;br /&gt;
| 40&lt;br /&gt;
|-&lt;br /&gt;
| Tilde (~)&lt;br /&gt;
| 41&lt;br /&gt;
|-&lt;br /&gt;
| Left Shift&lt;br /&gt;
| 42&lt;br /&gt;
|-&lt;br /&gt;
| Back Slash&lt;br /&gt;
| 43&lt;br /&gt;
|-&lt;br /&gt;
| Z&lt;br /&gt;
| 44&lt;br /&gt;
|-&lt;br /&gt;
| X&lt;br /&gt;
| 45&lt;br /&gt;
|-&lt;br /&gt;
| C&lt;br /&gt;
| 46&lt;br /&gt;
|-&lt;br /&gt;
| V&lt;br /&gt;
| 47&lt;br /&gt;
|}&lt;br /&gt;
|style=&amp;quot;vertical-align: top&amp;quot;|&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! |Key&lt;br /&gt;
! |Code&lt;br /&gt;
|-&lt;br /&gt;
| B&lt;br /&gt;
| 48&lt;br /&gt;
|-&lt;br /&gt;
| N&lt;br /&gt;
| 49&lt;br /&gt;
|-&lt;br /&gt;
| M&lt;br /&gt;
| 50&lt;br /&gt;
|-&lt;br /&gt;
| Comma&lt;br /&gt;
| 51&lt;br /&gt;
|-&lt;br /&gt;
| Period&lt;br /&gt;
| 52&lt;br /&gt;
|-&lt;br /&gt;
| Forward Slash&lt;br /&gt;
| 53&lt;br /&gt;
|-&lt;br /&gt;
| Right Shift&lt;br /&gt;
| 54&lt;br /&gt;
|-&lt;br /&gt;
| Numpad *&lt;br /&gt;
| 55&lt;br /&gt;
|-&lt;br /&gt;
| Left Alt&lt;br /&gt;
| 56&lt;br /&gt;
|-&lt;br /&gt;
| Spacebar&lt;br /&gt;
| 57&lt;br /&gt;
|-&lt;br /&gt;
| Caps Lock&lt;br /&gt;
| 58&lt;br /&gt;
|-&lt;br /&gt;
| F1&lt;br /&gt;
| 59&lt;br /&gt;
|-&lt;br /&gt;
| F2&lt;br /&gt;
| 60&lt;br /&gt;
|-&lt;br /&gt;
| F3&lt;br /&gt;
| 61&lt;br /&gt;
|-&lt;br /&gt;
| F4&lt;br /&gt;
| 62&lt;br /&gt;
|-&lt;br /&gt;
| F5&lt;br /&gt;
| 63&lt;br /&gt;
|-&lt;br /&gt;
| F6&lt;br /&gt;
| 64&lt;br /&gt;
|-&lt;br /&gt;
| F7&lt;br /&gt;
| 65&lt;br /&gt;
|-&lt;br /&gt;
| F8&lt;br /&gt;
| 66&lt;br /&gt;
|-&lt;br /&gt;
| F9&lt;br /&gt;
| 67&lt;br /&gt;
|-&lt;br /&gt;
| F10&lt;br /&gt;
| 68&lt;br /&gt;
|}&lt;br /&gt;
|style=&amp;quot;vertical-align: top&amp;quot;|&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! |Key&lt;br /&gt;
! |Code&lt;br /&gt;
|-&lt;br /&gt;
| Num Lock&lt;br /&gt;
| 69&lt;br /&gt;
|-&lt;br /&gt;
| Scroll Lock&lt;br /&gt;
| 70&lt;br /&gt;
|-&lt;br /&gt;
| Numpad 7&lt;br /&gt;
| 71&lt;br /&gt;
|-&lt;br /&gt;
| Numpad 8&lt;br /&gt;
| 72&lt;br /&gt;
|-&lt;br /&gt;
| Numpad 9&lt;br /&gt;
| 73&lt;br /&gt;
|-&lt;br /&gt;
| Numpad -&lt;br /&gt;
| 74&lt;br /&gt;
|-&lt;br /&gt;
| Numpad 4&lt;br /&gt;
| 75&lt;br /&gt;
|-&lt;br /&gt;
| Numpad 5&lt;br /&gt;
| 76&lt;br /&gt;
|-&lt;br /&gt;
| Numpad 6&lt;br /&gt;
| 77&lt;br /&gt;
|-&lt;br /&gt;
| Numpad +&lt;br /&gt;
| 78&lt;br /&gt;
|-&lt;br /&gt;
| Numpad 1&lt;br /&gt;
| 79&lt;br /&gt;
|-&lt;br /&gt;
| Numpad 2&lt;br /&gt;
| 80&lt;br /&gt;
|-&lt;br /&gt;
| Numpad 3&lt;br /&gt;
| 81&lt;br /&gt;
|-&lt;br /&gt;
| Numpad 0&lt;br /&gt;
| 82&lt;br /&gt;
|-&lt;br /&gt;
| Numpad .&lt;br /&gt;
| 83&lt;br /&gt;
|-&lt;br /&gt;
| F11&lt;br /&gt;
| 87&lt;br /&gt;
|-&lt;br /&gt;
| F12&lt;br /&gt;
| 88&lt;br /&gt;
|-&lt;br /&gt;
| Numpad Enter&lt;br /&gt;
| 156&lt;br /&gt;
|-&lt;br /&gt;
| Right Control&lt;br /&gt;
| 157&lt;br /&gt;
|-&lt;br /&gt;
| Numpad /&lt;br /&gt;
| 181&lt;br /&gt;
|-&lt;br /&gt;
| Right Alt&lt;br /&gt;
| 184&lt;br /&gt;
|}&lt;br /&gt;
|style=&amp;quot;vertical-align: top&amp;quot;|&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;5&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! |Key&lt;br /&gt;
! |Code&lt;br /&gt;
|-&lt;br /&gt;
| Home&lt;br /&gt;
| 199&lt;br /&gt;
|-&lt;br /&gt;
| Up Arrow&lt;br /&gt;
| 200&lt;br /&gt;
|-&lt;br /&gt;
| Page Up&lt;br /&gt;
| 201&lt;br /&gt;
|-&lt;br /&gt;
| Left Arrow&lt;br /&gt;
| 203&lt;br /&gt;
|-&lt;br /&gt;
| Right Arrow&lt;br /&gt;
| 205&lt;br /&gt;
|-&lt;br /&gt;
| End&lt;br /&gt;
| 207&lt;br /&gt;
|-&lt;br /&gt;
| Down Arrow&lt;br /&gt;
| 208&lt;br /&gt;
|-&lt;br /&gt;
| Page Down&lt;br /&gt;
| 209&lt;br /&gt;
|-&lt;br /&gt;
| Insert&lt;br /&gt;
| 210&lt;br /&gt;
|-&lt;br /&gt;
| Delete&lt;br /&gt;
| 211&lt;br /&gt;
|-&lt;br /&gt;
| Left Mouse Button&lt;br /&gt;
| 256&lt;br /&gt;
|-&lt;br /&gt;
| Right Mouse Button&lt;br /&gt;
| 257&lt;br /&gt;
|-&lt;br /&gt;
| Middle Mouse/Wheel&lt;br /&gt;
| 258&lt;br /&gt;
|-&lt;br /&gt;
| Mouse Button 3&lt;br /&gt;
| 259&lt;br /&gt;
|-&lt;br /&gt;
| Mouse Button 4&lt;br /&gt;
| 260&lt;br /&gt;
|-&lt;br /&gt;
| Mouse Button 5&lt;br /&gt;
| 261&lt;br /&gt;
|-&lt;br /&gt;
| Mouse Button 6&lt;br /&gt;
| 262&lt;br /&gt;
|-&lt;br /&gt;
| Mouse Button 7&lt;br /&gt;
| 263&lt;br /&gt;
|-&lt;br /&gt;
| Mouse Wheel Up&lt;br /&gt;
| 264&lt;br /&gt;
|-&lt;br /&gt;
| Mouse Wheel Down&lt;br /&gt;
| 265&lt;br /&gt;
|}&lt;br /&gt;
|}&lt;br /&gt;
Source: [http://wiki.tesnexus.com/index.php/DirectX_Scancodes_And_How_To_Use_Them Nexus Wiki]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Loops&amp;diff=1736</id>
		<title>Loops</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Loops&amp;diff=1736"/>
				<updated>2012-06-03T16:29:07Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Created page with &amp;quot;Category:Tutorials This is a tutorial page for loops and their application.  == Introducing Loops ==  At some point while coding, you will most likely want to run some cod...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Tutorials]]&lt;br /&gt;
This is a tutorial page for loops and their application.&lt;br /&gt;
&lt;br /&gt;
== Introducing Loops ==&lt;br /&gt;
&lt;br /&gt;
At some point while coding, you will most likely want to run some code multiple times, without writing out a lot of code. While it is true that functions can shorten your code, there may be situations where even thouse don't simplify it enough. That's where loops come in.&lt;br /&gt;
&lt;br /&gt;
Here is a script without loops&lt;br /&gt;
 local function GetName()&lt;br /&gt;
    write(&amp;quot;Enter a name: &amp;quot;)&lt;br /&gt;
    return read()&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 local Name1 = GetName()&lt;br /&gt;
 local Name2 = GetName()&lt;br /&gt;
 local Name3 = GetName()&lt;br /&gt;
 local Name4 = GetName()&lt;br /&gt;
 local Name5 = GetName()&lt;br /&gt;
 &lt;br /&gt;
 write(&amp;quot;You have entered &amp;quot;..Name1..&amp;quot; &amp;quot;..Name2..&amp;quot; &amp;quot;..Name3..&amp;quot; &amp;quot;..Name4..&amp;quot; &amp;quot;..Name5)&lt;br /&gt;
&lt;br /&gt;
As you can see, there is quite a lot of repetition, even when we're using a function.&lt;br /&gt;
&lt;br /&gt;
== The For loop ==&lt;br /&gt;
&lt;br /&gt;
The for loop is the most basic loop. It is in the following format&lt;br /&gt;
 for Variable = Start, End, Interval do&lt;br /&gt;
    --Insert code here&lt;br /&gt;
 end&lt;br /&gt;
Variable is a number that will track where we are in the loop. It is usually called &amp;quot;i&amp;quot;, or something more appropriate to the script. Start is a number to indicate the start point for the loop. This is generally 1, so the loop can count up easily. End is the number the loop will count to. Interval is an optional argument, and will specify how big the jumps would be . Ie, it specifies how much to add or subtract from Variable every loop.&lt;br /&gt;
&lt;br /&gt;
The best way to discover how the for loop works is to try it yourself. Try changing the numbers the following code to see how it reacts.&lt;br /&gt;
 for i=1,10 do&lt;br /&gt;
    print( &amp;quot;i is &amp;quot;..tostring(i) )&lt;br /&gt;
 end&lt;br /&gt;
Notice how it always counts up until Variable is the same or greater than End. Start, End, and Interval can also be variables, so it can loop a different number of times&lt;br /&gt;
 write(&amp;quot;How many times should I loop? &amp;quot;)&lt;br /&gt;
 local Num = tostring( read() )&lt;br /&gt;
 for i=1,Num do&lt;br /&gt;
    print(&amp;quot;Looped &amp;quot;..tostring(i)..&amp;quot; time(s).&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== The While loop ==&lt;br /&gt;
&lt;br /&gt;
The While loop will continue looping until a certain condition is met.&lt;br /&gt;
 local Answer, Correct = &amp;quot;&amp;quot;, &amp;quot;2&amp;quot;&lt;br /&gt;
 while Answer~=Correct do&lt;br /&gt;
    write(&amp;quot;What is the sum of 1 and 1 (1+1)? &amp;quot;)&lt;br /&gt;
    Answer = read()&lt;br /&gt;
    &lt;br /&gt;
    if Answer == Correct then print(&amp;quot;Correct!&amp;quot;) else print(&amp;quot;Incorrect!&amp;quot;) end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
This type of loop is useful for if you don't want to specify a definite end for the loop. Although infinite loops are ill-advised, you may want to use one at some point.&lt;br /&gt;
 while true do --Always loop&lt;br /&gt;
    --Code here&lt;br /&gt;
 end&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Tutorials&amp;diff=1735</id>
		<title>Tutorials</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Tutorials&amp;diff=1735"/>
				<updated>2012-06-03T16:02:53Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: /* Advanced tutorials */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As some tutorials might not be listed here, you can also browse the [[:Category:Tutorials|tutorials category]].&lt;br /&gt;
&lt;br /&gt;
== Before you begin ==&lt;br /&gt;
It is recommended that you read these pages before you begin working with ComputerCraft.&lt;br /&gt;
*[[Getting Started]]&lt;br /&gt;
*[[CraftOS Shell | Shell Commands]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Basic Tutorials ==&lt;br /&gt;
These tutorials are designed to be used in the order shown, each tutorial will build on the previous ones.&lt;br /&gt;
=== Introduction to Coding ===&lt;br /&gt;
*[[Hello_World_Tutorial|Hello World!]]&lt;br /&gt;
*[[Variables]]&lt;br /&gt;
*[[Conditional_statements|If, Then, Else]]&lt;br /&gt;
*[[Functions]]&lt;br /&gt;
*[[Loops]]&lt;br /&gt;
*[[Tables]]&lt;br /&gt;
&lt;br /&gt;
==Advanced tutorials==&lt;br /&gt;
These tutorials deal with specific functions that are not always necessary, but may help improve your code considerably.&lt;br /&gt;
===Coding for ComputerCraft===&lt;br /&gt;
*[[Raw key events]]&lt;br /&gt;
&lt;br /&gt;
== Exemplar Programs ==&lt;br /&gt;
These pages guide you through programs created by other users. They are not necessarily well-coded, but can be useful as a loose guide.&lt;br /&gt;
=== Programming &amp;amp; Wiring ===&lt;br /&gt;
*[[Making_a_Delay_function|Making a Delay (timer) function]]&lt;br /&gt;
*[[Guess_The_Number_(tutorial)|Guess the Number]]&lt;br /&gt;
*[[Making_a_Password_Protected_Door|Password Protected Door]]&lt;br /&gt;
*[[Making_an_API_(tutorial)|Programming an API]]&lt;br /&gt;
*[[Startup|Running script automatically at boot with Startup]]&lt;br /&gt;
*[[Raw key events| Detecting specific keys (such as the arrow keys)]]&lt;br /&gt;
*[[Receiving a rednet message through os.pullEvent()|Receiving a rednet message through os.pullEvent()]]&lt;br /&gt;
*[[Calculator_Tutorial]]&lt;br /&gt;
=== Turtles ===&lt;br /&gt;
The nice little robots that do the hard work for you.&lt;br /&gt;
*[[Turtle_Tutorial|Turtles!]]&lt;br /&gt;
*[[Turtle_Lumberjack_(tutorial)|Turtle Lumberjack]]&lt;br /&gt;
*[[Advanced_Turtle_Lumberjack_(tutorial)|Advanced Turtle Lumberjack]]&lt;br /&gt;
*[[Cobble_Generator|Cobblestone Generator]]&lt;br /&gt;
*[[Turtle_Stairbuilder_(tutorial)|Turtle Stairbuilder]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== External Tutorials/Guides ==&lt;br /&gt;
*[http://www.minecraftforum.net/topic/907632-mod-tutorial-computercraft-v12-very-basic-lua-tutorial-updated-1112/page__p__11556908#entry11556908 Onionnion's Basic Lua Tutorial]&lt;br /&gt;
*[http://www.computercraft.info/forums2/index.php?/topic/1516-ospullevent-what-is-it-and-how-is-it-useful/page__view__findpost__p__11156 Onionnion's os.pullEvent() Guide]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Hardcoded_Events&amp;diff=1734</id>
		<title>Hardcoded Events</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Hardcoded_Events&amp;diff=1734"/>
				<updated>2012-06-03T16:00:58Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are two hard-coded commands in ComputerCraft. To use these commands, you must hold down the appropriate key combination for at least 1 second.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;2&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
!style=&amp;quot;background:#EEE&amp;quot; width=&amp;quot;200px&amp;quot;|Shortcut&lt;br /&gt;
!style=&amp;quot;background:#EEE&amp;quot; width=&amp;quot;*&amp;quot;|Usage&lt;br /&gt;
|-&lt;br /&gt;
|CTRL + R&lt;br /&gt;
|Reboots the console.&lt;br /&gt;
|-&lt;br /&gt;
|CTRL + S&lt;br /&gt;
|Forcefully shuts down the computer.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
There is no way to override these commands. There is also another commonly used command, Ctrl+T to close the current program, but this is not hard-coded. To override this command, use [[Os#pullEvent|os.pullEvent]].&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Hardcoded_Events&amp;diff=1731</id>
		<title>Hardcoded Events</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Hardcoded_Events&amp;diff=1731"/>
				<updated>2012-06-03T13:58:36Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: moved Hardcode to Hardcoded Events: Disambiguous title&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are two hard-coded commands in ComputerCraft. To use these commands, you must hold down the appropriate key combination for about 1 second.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;2&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
!style=&amp;quot;background:#EEE&amp;quot; width=&amp;quot;200px&amp;quot;|Shortcut&lt;br /&gt;
!style=&amp;quot;background:#EEE&amp;quot; width=&amp;quot;*&amp;quot;|Usage&lt;br /&gt;
|-&lt;br /&gt;
|CTRL + R&lt;br /&gt;
|Reboots the console.&lt;br /&gt;
|-&lt;br /&gt;
|CTRL + S&lt;br /&gt;
|Forcefully shuts down the computer.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
There is no way to override these commands. There is also another commonly used command, Ctrl+T to close the current program, but this is not hard-coded. To override this command, use [[Os#pullEvent|os.pullEvent]].&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Hardcoded_Events&amp;diff=1730</id>
		<title>Hardcoded Events</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Hardcoded_Events&amp;diff=1730"/>
				<updated>2012-06-03T13:57:32Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are two hard-coded commands in ComputerCraft. To use these commands, you must hold down the appropriate key combination for about 1 second.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; cellpadding=&amp;quot;2&amp;quot; cellspacing=&amp;quot;0&amp;quot;&lt;br /&gt;
!style=&amp;quot;background:#EEE&amp;quot; width=&amp;quot;200px&amp;quot;|Shortcut&lt;br /&gt;
!style=&amp;quot;background:#EEE&amp;quot; width=&amp;quot;*&amp;quot;|Usage&lt;br /&gt;
|-&lt;br /&gt;
|CTRL + R&lt;br /&gt;
|Reboots the console.&lt;br /&gt;
|-&lt;br /&gt;
|CTRL + S&lt;br /&gt;
|Forcefully shuts down the computer.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
There is no way to override these commands. There is also another commonly used command, Ctrl+T to close the current program, but this is not hard-coded. To override this command, use [[Os#pullEvent|os.pullEvent]].&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Tutorials&amp;diff=1726</id>
		<title>Tutorials</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Tutorials&amp;diff=1726"/>
				<updated>2012-06-02T00:53:01Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: /* Introduction to Coding */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As some tutorials might not be listed here, you can also browse the [[:Category:Tutorials|tutorials category]].&lt;br /&gt;
&lt;br /&gt;
== Before you begin ==&lt;br /&gt;
It is recommended that you read these pages before you begin working with ComputerCraft.&lt;br /&gt;
*[[Getting Started]]&lt;br /&gt;
*[[CraftOS Shell | Shell Commands]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Basic Tutorials ==&lt;br /&gt;
These tutorials are designed to be used in the order shown, each tutorial will build on the previous ones.&lt;br /&gt;
=== Introduction to Coding ===&lt;br /&gt;
*[[Hello_World_Tutorial|Hello World!]]&lt;br /&gt;
*[[Variables]]&lt;br /&gt;
*[[Conditional_statements|If, Then, Else]]&lt;br /&gt;
*[[Functions]]&lt;br /&gt;
*[[Loops]]&lt;br /&gt;
*[[Tables]]&lt;br /&gt;
&lt;br /&gt;
==Advanced tutorials==&lt;br /&gt;
These tutorials deal with specific functions you might not need.&lt;br /&gt;
===Coding for ComputerCraft===&lt;br /&gt;
*[[Raw key events]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Exemplar Programs ==&lt;br /&gt;
These pages guide you through programs created by other users. They are not necessarily well-coded, but can be useful as a loose guide.&lt;br /&gt;
=== Programming &amp;amp; Wiring ===&lt;br /&gt;
*[[Making_a_Delay_function|Making a Delay (timer) function]]&lt;br /&gt;
*[[Guess_The_Number_(tutorial)|Guess the Number]]&lt;br /&gt;
*[[Making_a_Password_Protected_Door|Password Protected Door]]&lt;br /&gt;
*[[Making_an_API_(tutorial)|Programming an API]]&lt;br /&gt;
*[[Startup|Running script automatically at boot with Startup]]&lt;br /&gt;
*[[Raw key events| Detecting specific keys (such as the arrow keys)]]&lt;br /&gt;
*[[Receiving a rednet message through os.pullEvent()|Receiving a rednet message through os.pullEvent()]]&lt;br /&gt;
*[[Calculator_Tutorial]]&lt;br /&gt;
=== Turtles ===&lt;br /&gt;
The nice little robots that do the hard work for you.&lt;br /&gt;
*[[Turtle_Tutorial|Turtles!]]&lt;br /&gt;
*[[Turtle_Lumberjack_(tutorial)|Turtle Lumberjack]]&lt;br /&gt;
*[[Advanced_Turtle_Lumberjack_(tutorial)|Advanced Turtle Lumberjack]]&lt;br /&gt;
*[[Cobble_Generator|Cobblestone Generator]]&lt;br /&gt;
*[[Turtle_Stairbuilder_(tutorial)|Turtle Stairbuilder]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== External Tutorials/Guides ==&lt;br /&gt;
*[http://www.minecraftforum.net/topic/907632-mod-tutorial-computercraft-v12-very-basic-lua-tutorial-updated-1112/page__p__11556908#entry11556908 Onionnion's Basic Lua Tutorial]&lt;br /&gt;
*[http://www.computercraft.info/forums2/index.php?/topic/1516-ospullevent-what-is-it-and-how-is-it-useful/page__view__findpost__p__11156 Onionnion's os.pullEvent() Guide]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Tables&amp;diff=1725</id>
		<title>Tables</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Tables&amp;diff=1725"/>
				<updated>2012-06-02T00:51:34Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Created page with &amp;quot;Category:Tutorials This script will introduce you to tables, and show you some ways to use them. If you have experience with other languages, a table is roughly equivalent...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Tutorials]]&lt;br /&gt;
This script will introduce you to tables, and show you some ways to use them.&lt;br /&gt;
If you have experience with other languages, a table is roughly equivalent to an array.&lt;br /&gt;
&lt;br /&gt;
== Why are tables useful? ==&lt;br /&gt;
&lt;br /&gt;
Tables can simplify code considerably, by grouping like variables and functions together.&lt;br /&gt;
&lt;br /&gt;
In this example, we're getting a list of student's names&lt;br /&gt;
Code without tables&lt;br /&gt;
 local StudentName1 = &amp;quot;Andrew&amp;quot;&lt;br /&gt;
 local StudentName2 = &amp;quot;Alfred&amp;quot;&lt;br /&gt;
 local StudentName3 = &amp;quot;Alex&amp;quot;&lt;br /&gt;
 local StudentName4 = &amp;quot;Amber&amp;quot;&lt;br /&gt;
 local StudentName5 = &amp;quot;Alice&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Code with tables&lt;br /&gt;
 local StudentNames = {&amp;quot;Andrew&amp;quot;, &amp;quot;Alfred&amp;quot;, &amp;quot;Alex&amp;quot;, &amp;quot;Amber&amp;quot;, &amp;quot;Alice&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
As you can see, the first example needs 5 unique variables being defined individually, while the second example, using the table, is all one line with one variable.&lt;br /&gt;
&lt;br /&gt;
Note the { and }, this is how you spot a table. Anything between them is a variable to be stored in the table. A table is not restricted to one variable type, and you can even store tables within tables if you wish&lt;br /&gt;
&lt;br /&gt;
== Using the table ==&lt;br /&gt;
&lt;br /&gt;
There are a number of ways to set the values in a table. The first, as shown above, is the simplest method, and will give each value a unique number as the &amp;quot;key&amp;quot;. The key is simply the location in the table, it's usually a number or string. This method always clears the contents of the table and replaces it with what you've specified. Note that setting a table to &amp;quot;{}&amp;quot; is valid, and is commonly used if the values don't need to, or can't, be set immediately. You may find yourself using &amp;quot;Variable={}&amp;quot; often. Setting a specific key with this method is relatively simple, you just use the asignment operator &amp;quot;=&amp;quot; and treat the key as a variable&lt;br /&gt;
 local Table = {Key1 = &amp;quot;First key!&amp;quot;, Key2 = &amp;quot;Second key!&amp;quot;}&lt;br /&gt;
&lt;br /&gt;
It can also be defined over multiple lines, to help with readability, if you end the line with a comma rather than the } to close it. Just remember to add the } when you're done.&lt;br /&gt;
 local Table = {&amp;quot;Stuff&amp;quot;, 1, 2, &amp;quot;More stuff&amp;quot;,&lt;br /&gt;
     3, &amp;quot;Some strings&amp;quot;,&lt;br /&gt;
     function() end}&lt;br /&gt;
&lt;br /&gt;
Another method is to use the square parenthesis [ and ] to specify the key. This method requires the table to have already been created, using { and }, otherwise it will give you an error. Using this method will treat it as a regular variable, so you can both set and read the value with this method. This method is commonly used for getting a value when the key is a number.&lt;br /&gt;
 local Table = {}&lt;br /&gt;
 Table[&amp;quot;Boolean&amp;quot;] = true&lt;br /&gt;
 &lt;br /&gt;
 if Table[&amp;quot;Boolean&amp;quot;] then print(&amp;quot;The value is true!&amp;quot;) end&lt;br /&gt;
&lt;br /&gt;
If you need to reference a table within a table using this method, you can simply add another [ ]&lt;br /&gt;
&lt;br /&gt;
 local Table = {&amp;quot;Value&amp;quot;, 2, {true, false}}&lt;br /&gt;
 &lt;br /&gt;
 if Table[3][2] then print(&amp;quot;The value is true!&amp;quot;) else print(&amp;quot;The value is false!&amp;quot;) end&lt;br /&gt;
&lt;br /&gt;
A third method is to simply add the key onto the end of the table name, separated by a &amp;quot;.&amp;quot;. Like the previous method, this method requires the table to already exist. It can also be treated as a regular variable, as above. This method is commonly used for when the key is a string.&lt;br /&gt;
 local Table = {}&lt;br /&gt;
 &lt;br /&gt;
 Table.key = true&lt;br /&gt;
 if Table.key then print(&amp;quot;True!&amp;quot;) end&lt;br /&gt;
&lt;br /&gt;
As with the second method, to index a table within a table you just add the second key to the end. Note that these methods are interchangeable, and can all be used at the same time.&lt;br /&gt;
&lt;br /&gt;
It is not advisable to have many tables inside each other, especially if they are similarly named&lt;br /&gt;
 local Table = {String = &amp;quot;This is a string!&amp;quot;, Table = {Number = 2, Table = {func = write, Table = {Bool = true} } }}&lt;br /&gt;
 &lt;br /&gt;
 if Table[Table].Table.Table.Bool then print(&amp;quot;True!&amp;quot;) end&lt;br /&gt;
&lt;br /&gt;
If you don't mind being restricted to number keys, you could use the table.insert(Table, [Position,] Value ) function.&lt;br /&gt;
 local Table = {&amp;quot;One&amp;quot;}&lt;br /&gt;
 table.insert(Table, &amp;quot;Three&amp;quot;) --This inserts the string &amp;quot;Three&amp;quot; to the end of the table (At key 2)&lt;br /&gt;
 table.insert(Table, 2, &amp;quot;Two&amp;quot;) --This inserts the string &amp;quot;Two&amp;quot; to key 2, pushing the string &amp;quot;Three&amp;quot; up to key three&lt;br /&gt;
 --End result, Table[1] is One, Table[2] is Two, Table[3] is Three&lt;br /&gt;
&lt;br /&gt;
== Tables and Loops ==&lt;br /&gt;
&lt;br /&gt;
When you combine tables and loops, they suddenly become a lot more useful. You can run through a table easily, using or changing each value.&lt;br /&gt;
 local Table = {&amp;quot;Hello! &amp;quot;, &amp;quot;This string &amp;quot;, &amp;quot;was read from &amp;quot;, &amp;quot;a table!&amp;quot;, &amp;quot;\n&amp;quot;}&lt;br /&gt;
 for i=1,#Table do&lt;br /&gt;
    write( Table[i] )&lt;br /&gt;
 end&lt;br /&gt;
This will write &amp;quot;Hello! This string was read from a table!&amp;quot; followed by a new line. You may notice there's a &amp;quot;#&amp;quot; behind Table, this simply returns the number of values in the table. It can also be sued to get the length of a string.&lt;br /&gt;
&lt;br /&gt;
The standard for loop does, however, come with an inherent disadvantage in that it can only (easily) access consecutive numerical strings, ie 1,2,3 but not 1,2,4. to get around this, we can use &amp;quot;pairs&amp;quot; and &amp;quot;ipairs&amp;quot;. &amp;quot;pairs&amp;quot; and &amp;quot;ipairs&amp;quot; use a table to loop, by running through the keys and values for the number that exist in the table.&lt;br /&gt;
 local Table = {StartTime = 0.5, EndTime = 1.5}&lt;br /&gt;
 &lt;br /&gt;
 for key,value in pairs( Table ) do&lt;br /&gt;
    print( tostring(key) ..&amp;quot;: &amp;quot;..tostring(value))&lt;br /&gt;
 end&lt;br /&gt;
This will output equivalent to &amp;quot;EndTime: 1.5\nStartTime: 0.5&amp;quot;. Not that ipairs is identical to pairs, except it tries to do it in order.&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Conditional_statements&amp;diff=1724</id>
		<title>Conditional statements</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Conditional_statements&amp;diff=1724"/>
				<updated>2012-06-01T23:44:39Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: /* The If statement */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Tutorials]]&lt;br /&gt;
This is a tutorial will teach you how to make your script react to different situations.&lt;br /&gt;
&lt;br /&gt;
== The If statement ==&lt;br /&gt;
&lt;br /&gt;
Conditional statements are one of the fundamental building blocks for any coding languages. They are just as they sound, if a condition is met then a block of code will run. The simplest form of conditional statement available in Lua is the &amp;quot;If&amp;quot; statement, which indicates that if one or more conditions are met, the following block of code will run. If statements take the following format&lt;br /&gt;
  local Variable = 1&lt;br /&gt;
  if Variable==1 then&lt;br /&gt;
    write(&amp;quot;The variable is 1!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
  if Variable==2 then&lt;br /&gt;
    write(&amp;quot;The variable is 2!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This script will simply output the text &amp;quot;The variable is 1!&amp;quot;. The &amp;quot;==&amp;quot; operator simply means &amp;quot;is equal to&amp;quot;, so the line reads along the lines of &amp;quot;If Variable is equal to 1, then do this&amp;quot;. &amp;quot;end&amp;quot; marks the end of the code block, and anything after it is run normally regardless of whether the conditions were met.&lt;br /&gt;
&lt;br /&gt;
Brackets may optionally be used around conditions, although it is not necessary unless you want to control the order of a calculation.&lt;br /&gt;
&lt;br /&gt;
Note that since lua disregards new lines, it would be equally acceptable to write the following&lt;br /&gt;
 if Variable==1 then write(&amp;quot;The variable is 1!\n&amp;quot;) end&lt;br /&gt;
However, this method is generally less readable and not commonly used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lua determines whether an if statement passes by using the boolean values returned by the condition, so it would be possible (but unnecessary) to enter a boolean as the condition&lt;br /&gt;
 if true then write(&amp;quot;This will always write!\n&amp;quot;) end&lt;br /&gt;
 if false then write(&amp;quot;This will never write!\n&amp;quot;) end&lt;br /&gt;
&lt;br /&gt;
== Available conditions ==&lt;br /&gt;
There are a number of different conditions that can be used to make the &lt;br /&gt;
&lt;br /&gt;
;Is equal to&lt;br /&gt;
  if Variable == Variable2 then&lt;br /&gt;
    --Do stuff&lt;br /&gt;
  end&lt;br /&gt;
The &amp;quot;==&amp;quot; condition is the most basic operator, simply comparing two values to see if they are the same. If both values are the same, the condition is met and the if statement passes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Is not equal to&lt;br /&gt;
  if Variable ~= Variable2 then&lt;br /&gt;
    --Do stuff&lt;br /&gt;
  end&lt;br /&gt;
The &amp;quot;~=&amp;quot; condition compares two values to see if they are the same, and if they are ''not'' the same, the condition is met and the if statement passes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Greater than&lt;br /&gt;
  if Number &amp;gt; Number2 then&lt;br /&gt;
    --Do stuff&lt;br /&gt;
  end&lt;br /&gt;
The &amp;quot;&amp;gt;&amp;quot; condition compares two number values, and if the first is greater than the second, the condition is met and the if statement passes. The &amp;quot;&amp;gt;=&amp;quot; (Greater than or equal to) operator acts as both the &amp;quot;greater than&amp;quot; and the &amp;quot;equal to&amp;quot; conditions, meaning the condition is met if either the first number is equal to the second, or the first number is greater than the second.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Less than&lt;br /&gt;
  if Number &amp;lt; Number2 then&lt;br /&gt;
    --Do stuff&lt;br /&gt;
  end&lt;br /&gt;
The &amp;quot;&amp;lt;&amp;quot; condition compares two number values, and if the first is lower than the second, the condition is met and the if statement passes. The &amp;quot;&amp;lt;=&amp;quot; (Less than or equal to) operator acts as a combination of the &amp;quot;less than&amp;quot; and the &amp;quot;equal to&amp;quot; conditions.&lt;br /&gt;
&lt;br /&gt;
=== And, Or, Not ===&lt;br /&gt;
&lt;br /&gt;
Sometimes it is desirable to combine conditions. Although it is possible to use multiple if statements, or ifs inside ifs, it is a best practice to use &amp;quot;and&amp;quot; and &amp;quot;or&amp;quot; if possible.&lt;br /&gt;
&lt;br /&gt;
;And&lt;br /&gt;
 local Num1,Num2,Num3 = 1,2,3&lt;br /&gt;
 &lt;br /&gt;
 --Multiple if&lt;br /&gt;
 if Num1 &amp;gt; Num2 then&lt;br /&gt;
   if Num2 &amp;lt; Num3 then&lt;br /&gt;
     write(&amp;quot;Condition is true!&amp;quot;)&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 --Using And&lt;br /&gt;
 if (Num1&amp;gt;Num2) and (Num2&amp;lt;Num3) then&lt;br /&gt;
   write(&amp;quot;Condition is true!&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;and&amp;quot; operator means that both conditions must match before the statement passes. If either side fails, the whole condition is false. Note that if the left side fails, the right side is ignored, so if you have a critical function it should be on the left of the &amp;quot;and&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
;Or&lt;br /&gt;
 local Num1,Num2,Num3 = 1,2,3&lt;br /&gt;
 &lt;br /&gt;
 --Multiple if&lt;br /&gt;
 if Num1 &amp;gt; Num2 then&lt;br /&gt;
   write(&amp;quot;Condition is true!&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
 if Num2 &amp;lt; Num3 then&lt;br /&gt;
   write(&amp;quot;Condition is true!&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 --Using Or&lt;br /&gt;
 if (Num1&amp;gt;Num2) or (Num2&amp;lt;Num3) then&lt;br /&gt;
   write(&amp;quot;Condition is true!&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;or&amp;quot; operator means that if either condition matches the statement passes. This means that if either the left side, the right side, or both pass, the statement is true. Note that if the left side passes, the right side is ignored, so if you have a critical function it should be on the left of the &amp;quot;or&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
;Not&lt;br /&gt;
 local Num1,Num2,Num3 = 1,2,3&lt;br /&gt;
 &lt;br /&gt;
 if (Num1 &amp;lt; Num2) and not (Num1 &amp;gt; Num3) then&lt;br /&gt;
   write(&amp;quot;Condition is true!&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
While the &amp;quot;not&amp;quot; statement is rarely a necessity, it can be used to reverse a value from &amp;quot;true&amp;quot; to &amp;quot;false&amp;quot; or vice versa.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In some situations, it may be preferable not to use these statements as code will run before the second condition needs to be assessed, such as as follows&lt;br /&gt;
 local Num1,Num2 = 1,2&lt;br /&gt;
 &lt;br /&gt;
 --And should not be used here&lt;br /&gt;
 if Num1&amp;gt;Num2 then&lt;br /&gt;
   local Num3 = 3&lt;br /&gt;
   &lt;br /&gt;
   if Num3&amp;gt;Num2 then write(&amp;quot;Text!\n&amp;quot;) end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== The Else statement ==&lt;br /&gt;
&lt;br /&gt;
It is common that you may want to run some code on the failure of the condition. If this is the case, it may be achieved through the use of two separate if statements, but it's simpler to use the &amp;quot;else&amp;quot; statement.&lt;br /&gt;
  local Num1 = 1&lt;br /&gt;
  local Num2 = 2&lt;br /&gt;
  &lt;br /&gt;
  --Using multiple if&lt;br /&gt;
  if Num1 &amp;gt; Num2 then&lt;br /&gt;
    write(&amp;quot;Number 1 is greater!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
  if Num1 &amp;lt;= Num2 then&lt;br /&gt;
    write(&amp;quot;Number 1 is not greater!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
  --Using else&lt;br /&gt;
  if Num1&amp;gt;Num2 then&lt;br /&gt;
    write(&amp;quot;Number 1 is greater!\n&amp;quot;)&lt;br /&gt;
  else&lt;br /&gt;
    write(&amp;quot;Number 1 is not greater!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== The ElseIf statement ==&lt;br /&gt;
&lt;br /&gt;
Sometimes it may be desirable to run the &amp;quot;else&amp;quot; code only under certain conditions. This is where &amp;quot;elseif&amp;quot; becomes useful. It acts as if it is another if statement, but also functions as the &amp;quot;else&amp;quot; of the if it's in.&lt;br /&gt;
&lt;br /&gt;
 local Num1, Num2, Num3 = 1,2,3&lt;br /&gt;
 &lt;br /&gt;
 --Without elseif&lt;br /&gt;
 if Num1&amp;gt;Num2 then&lt;br /&gt;
   write(&amp;quot;First condition passed!\n&amp;quot;)&lt;br /&gt;
 elseif Num3&amp;gt;Num2 then&lt;br /&gt;
   write(&amp;quot;First condition failed, second condition passed!\n&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;elseif&amp;quot; statement can become even more useful if you chain together more &amp;quot;elseif&amp;quot;s and &amp;quot;else&amp;quot;s with it, but remember that the first if that passes will break the chain!&lt;br /&gt;
 if Bool then&lt;br /&gt;
   --Stuff&lt;br /&gt;
 elseif Var1 == Var2 then&lt;br /&gt;
   --Other stuff&lt;br /&gt;
 elseif Table[1] then&lt;br /&gt;
   --More stuff&lt;br /&gt;
 else&lt;br /&gt;
   --More again!&lt;br /&gt;
 end&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Function_(type)&amp;diff=1723</id>
		<title>Function (type)</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Function_(type)&amp;diff=1723"/>
				<updated>2012-06-01T23:43:28Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Tutorials]]&lt;br /&gt;
An introduction to functions&lt;br /&gt;
&lt;br /&gt;
== What are functions? ==&lt;br /&gt;
&lt;br /&gt;
Functions are a useful tool that helps simplify code, separating it by functionality and reducing repetitiveness. Understanding functions is key to becoming a successful coder. When a function is defined in lua, it will most likely look like this:&lt;br /&gt;
 function FunctionName()&lt;br /&gt;
   --Do stuff&lt;br /&gt;
 end&lt;br /&gt;
But may occasionally look more like a regular variable&lt;br /&gt;
 FunctionName = function()&lt;br /&gt;
   --Do stuff&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Both methods will yield the same result, so it's generally down to personal preference. Since functions are treated as normal variables, it is also possible to copy a function to a new variable&lt;br /&gt;
 NewFunctionName = OldFunctionName&lt;br /&gt;
Note that here, we aren't using the &amp;quot;()&amp;quot; present in the other methods. This is because we're using OldFunctionName as a variable, and not as a function.&lt;br /&gt;
&lt;br /&gt;
== How do I use functions? ==&lt;br /&gt;
&lt;br /&gt;
More than likely, if you've followed the &amp;quot;Hello World&amp;quot; tutorial, you have already used functions. Without standard in-built functions such as write() and print(), it would be impossible to interact with a user. Whenever you see brackets after a variable name, you know it's a function.&lt;br /&gt;
&lt;br /&gt;
For our first example, we will write a simple function that will use write()&lt;br /&gt;
 function MyFunction( Str )&lt;br /&gt;
   write( Str )&lt;br /&gt;
 end&lt;br /&gt;
 MyFunction( &amp;quot;I am writing text to the screen!\n&amp;quot; )&lt;br /&gt;
&lt;br /&gt;
If you have successfully written and executed this script, it should write &amp;quot;I am writing text to the screen!&amp;quot; on the screen. Notice how the function has a variable name in the brackets. This is called an &amp;quot;argument&amp;quot;, and will likely be crucial to your functions later. There can be any number of arguments, separated by commas, and arguments can be any type of variable, including other functions.&lt;br /&gt;
&lt;br /&gt;
Add the following line to your code&lt;br /&gt;
 MyFunction( true )&lt;br /&gt;
This will pass a boolean value to your function, and it will error as it reaches the write(), which can't use a boolean value. To fix this, we'll need to validate what type of variable is being given. Try adding another line so your code looks like this:&lt;br /&gt;
 function MyFunction( Str )&lt;br /&gt;
   if type(Str) ~= &amp;quot;string&amp;quot; then return end&lt;br /&gt;
   write( Str )&lt;br /&gt;
 end&lt;br /&gt;
 MyFunction( &amp;quot;I am writing text to the screen!\n&amp;quot; )&lt;br /&gt;
 MyFunction( true )&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;type&amp;quot; functions will give you a string with the type of variable you give it. In this case, if the variable is not a string, it will run &amp;quot;return&amp;quot;. Return will be described in more detail later in this tutorial, but for now we only need to know it ends the function, so any code after it will not be run. If you run your script now, you will see that there will be no error when it tries to use the boolean value. In fact, it will produce nothing at all, which may not be desirable. Edit the return line so it reads as follows&lt;br /&gt;
 if type(Str) ~= &amp;quot;string&amp;quot; then write(&amp;quot;Bad argument #1 to MyFuction: String expected, got &amp;quot;..type(Str)..&amp;quot;!\n&amp;quot;) return end&lt;br /&gt;
If you run the code again, you will find it now gives an error when it reaches the boolean. The difference between this and the usual error() command called for a real error, is that this won't exit your code, and any line afterwards will still run as normal.&lt;br /&gt;
&lt;br /&gt;
All this script really does is give a new name to the write() function, so there is a simpler way to do it. Before reading the following code, see if you can use your current knowledge to work it out for yourself.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The simplest way to get a new name for a function is as follows.&lt;br /&gt;
 MyFunction = write&lt;br /&gt;
This means that any call to MyFunction() will act as write() did. Note that any changes to write() ''after'' this line will not edit MyFunction, which is why this method is often used to back up a built-in function before it's overwritten. As an example, someone may want to disable the write() function, but still have a way to use it when necessary.&lt;br /&gt;
 MyFunction = write&lt;br /&gt;
 write = function() MyFunction(&amp;quot;This function has been disabled!\n&amp;quot;) end&lt;br /&gt;
This will write &amp;quot;This function has been disabled!&amp;quot; every time someone tries to use write()&lt;br /&gt;
&lt;br /&gt;
== Return ==&lt;br /&gt;
&lt;br /&gt;
Sometimes you will want a function to give a value back when it is done. This is the purpose of &amp;quot;return&amp;quot;, it will return one or more values and end the function.&lt;br /&gt;
 local function RandomNumber()&lt;br /&gt;
   local rand = math.random(0,10)&lt;br /&gt;
   return rand&lt;br /&gt;
 end&lt;br /&gt;
 local Num = RandomNumber()&lt;br /&gt;
&lt;br /&gt;
This will set Num to a random number between 0 and 1. Notice how this time we are including the () for the function, this means we're calling the function rather than using it as a variable.&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Tutorials&amp;diff=1722</id>
		<title>Tutorials</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Tutorials&amp;diff=1722"/>
				<updated>2012-06-01T23:27:50Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As some tutorials might not be listed here, you can also browse the [[:Category:Tutorials|tutorials category]].&lt;br /&gt;
&lt;br /&gt;
== Before you begin ==&lt;br /&gt;
It is recommended that you read these pages before you begin working with ComputerCraft.&lt;br /&gt;
*[[Getting Started]]&lt;br /&gt;
*[[CraftOS Shell | Shell Commands]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Basic Tutorials ==&lt;br /&gt;
These tutorials are designed to be used in the order shown, each tutorial will build on the previous ones.&lt;br /&gt;
=== Introduction to Coding ===&lt;br /&gt;
*[[Hello_World_Tutorial|Hello World!]]&lt;br /&gt;
*[[Variables]]&lt;br /&gt;
*[[Conditional_statements|If, Then, Else]]&lt;br /&gt;
*[[Functions]]&lt;br /&gt;
&lt;br /&gt;
==Advanced tutorials==&lt;br /&gt;
These tutorials deal with specific functions you might not need.&lt;br /&gt;
===Coding for ComputerCraft===&lt;br /&gt;
*[[Raw key events]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Exemplar Programs ==&lt;br /&gt;
These pages guide you through programs created by other users. They are not necessarily well-coded, but can be useful as a loose guide.&lt;br /&gt;
=== Programming &amp;amp; Wiring ===&lt;br /&gt;
*[[Making_a_Delay_function|Making a Delay (timer) function]]&lt;br /&gt;
*[[Guess_The_Number_(tutorial)|Guess the Number]]&lt;br /&gt;
*[[Making_a_Password_Protected_Door|Password Protected Door]]&lt;br /&gt;
*[[Making_an_API_(tutorial)|Programming an API]]&lt;br /&gt;
*[[Startup|Running script automatically at boot with Startup]]&lt;br /&gt;
*[[Raw key events| Detecting specific keys (such as the arrow keys)]]&lt;br /&gt;
*[[Receiving a rednet message through os.pullEvent()|Receiving a rednet message through os.pullEvent()]]&lt;br /&gt;
*[[Calculator_Tutorial]]&lt;br /&gt;
=== Turtles ===&lt;br /&gt;
The nice little robots that do the hard work for you.&lt;br /&gt;
*[[Turtle_Tutorial|Turtles!]]&lt;br /&gt;
*[[Turtle_Lumberjack_(tutorial)|Turtle Lumberjack]]&lt;br /&gt;
*[[Advanced_Turtle_Lumberjack_(tutorial)|Advanced Turtle Lumberjack]]&lt;br /&gt;
*[[Cobble_Generator|Cobblestone Generator]]&lt;br /&gt;
*[[Turtle_Stairbuilder_(tutorial)|Turtle Stairbuilder]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== External Tutorials/Guides ==&lt;br /&gt;
*[http://www.minecraftforum.net/topic/907632-mod-tutorial-computercraft-v12-very-basic-lua-tutorial-updated-1112/page__p__11556908#entry11556908 Onionnion's Basic Lua Tutorial]&lt;br /&gt;
*[http://www.computercraft.info/forums2/index.php?/topic/1516-ospullevent-what-is-it-and-how-is-it-useful/page__view__findpost__p__11156 Onionnion's os.pullEvent() Guide]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Tutorials&amp;diff=1721</id>
		<title>Tutorials</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Tutorials&amp;diff=1721"/>
				<updated>2012-06-01T23:25:37Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As some tutorials might not be listed here, you can also browse the [[:Category:Tutorials|tutorials category]].&lt;br /&gt;
&lt;br /&gt;
== Before you begin ==&lt;br /&gt;
It is recommended that you read these pages before you begin working with ComputerCraft.&lt;br /&gt;
*[[Getting Started]]&lt;br /&gt;
*[[CraftOS Shell | Shell Commands]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Basic Tutorials ==&lt;br /&gt;
These tutorials are designed to be used in the order shown, each tutorial will build on the previous ones.&lt;br /&gt;
=== Introduction to Coding ===&lt;br /&gt;
*[[Hello_World_Tutorial|Hello World!]]&lt;br /&gt;
*[[Variables]]&lt;br /&gt;
*[[Conditional_statements|If, Then, Else]]&lt;br /&gt;
*[[Functions]]&lt;br /&gt;
&lt;br /&gt;
===Coding for ComputerCraft===&lt;br /&gt;
*[[Raw key events]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Exemplar Programs ==&lt;br /&gt;
These pages guide you through programs created by other users. They are not necessarily well-coded, but can be useful as a loose guide.&lt;br /&gt;
=== Programming &amp;amp; Wiring ===&lt;br /&gt;
*[[Making_a_Delay_function|Making a Delay (timer) function]]&lt;br /&gt;
*[[Guess_The_Number_(tutorial)|Guess the Number]]&lt;br /&gt;
*[[Making_a_Password_Protected_Door|Password Protected Door]]&lt;br /&gt;
*[[Making_an_API_(tutorial)|Programming an API]]&lt;br /&gt;
*[[Startup|Running script automatically at boot with Startup]]&lt;br /&gt;
*[[Raw key events| Detecting specific keys (such as the arrow keys)]]&lt;br /&gt;
*[[Receiving a rednet message through os.pullEvent()|Receiving a rednet message through os.pullEvent()]]&lt;br /&gt;
*[[Calculator_Tutorial]]&lt;br /&gt;
=== Turtles ===&lt;br /&gt;
The nice little robots that do the hard work for you.&lt;br /&gt;
*[[Turtle_Tutorial|Turtles!]]&lt;br /&gt;
*[[Turtle_Lumberjack_(tutorial)|Turtle Lumberjack]]&lt;br /&gt;
*[[Advanced_Turtle_Lumberjack_(tutorial)|Advanced Turtle Lumberjack]]&lt;br /&gt;
*[[Cobble_Generator|Cobblestone Generator]]&lt;br /&gt;
*[[Turtle_Stairbuilder_(tutorial)|Turtle Stairbuilder]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== External Tutorials/Guides ==&lt;br /&gt;
*[http://www.minecraftforum.net/topic/907632-mod-tutorial-computercraft-v12-very-basic-lua-tutorial-updated-1112/page__p__11556908#entry11556908 Onionnion's Basic Lua Tutorial]&lt;br /&gt;
*[http://www.computercraft.info/forums2/index.php?/topic/1516-ospullevent-what-is-it-and-how-is-it-useful/page__view__findpost__p__11156 Onionnion's os.pullEvent() Guide]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Tutorials&amp;diff=1720</id>
		<title>Tutorials</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Tutorials&amp;diff=1720"/>
				<updated>2012-06-01T23:24:47Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: /* Basic Tutorials */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As some tutorials might not be listed here, you can also browse the [[:Category:Tutorials|tutorials category]].&lt;br /&gt;
&lt;br /&gt;
== Before you begin ==&lt;br /&gt;
It is recommended that you read these pages before you begin working with ComputerCraft.&lt;br /&gt;
*[[Getting Started]]&lt;br /&gt;
*[[CraftOS Shell | Shell Commands]]&lt;br /&gt;
&lt;br /&gt;
== Basic Tutorials ==&lt;br /&gt;
These tutorials are designed to be used in the order shown, each tutorial will build on the previous ones.&lt;br /&gt;
=== Introduction to Coding ===&lt;br /&gt;
*[[Hello_World_Tutorial|Hello World!]]&lt;br /&gt;
*[[Variables]]&lt;br /&gt;
*[[Conditional_statements|If, Then, Else]]&lt;br /&gt;
*[[Functions]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Coding for ComputerCraft===&lt;br /&gt;
*[[Raw key events]]&lt;br /&gt;
&lt;br /&gt;
== Exemplar Programs ==&lt;br /&gt;
These pages guide you through programs created by other users. They are not necessarily well-coded, but can be useful as a loose guide.&lt;br /&gt;
=== Programming &amp;amp; Wiring ===&lt;br /&gt;
*[[Making_a_Delay_function|Making a Delay (timer) function]]&lt;br /&gt;
*[[Guess_The_Number_(tutorial)|Guess the Number]]&lt;br /&gt;
*[[Making_a_Password_Protected_Door|Password Protected Door]]&lt;br /&gt;
*[[Making_an_API_(tutorial)|Programming an API]]&lt;br /&gt;
*[[Startup|Running script automatically at boot with Startup]]&lt;br /&gt;
*[[Raw key events| Detecting specific keys (such as the arrow keys)]]&lt;br /&gt;
*[[Receiving a rednet message through os.pullEvent()|Receiving a rednet message through os.pullEvent()]]&lt;br /&gt;
*[[Calculator_Tutorial]]&lt;br /&gt;
=== Turtles ===&lt;br /&gt;
The nice little robots that do the hard work for you.&lt;br /&gt;
*[[Turtle_Tutorial|Turtles!]]&lt;br /&gt;
*[[Turtle_Lumberjack_(tutorial)|Turtle Lumberjack]]&lt;br /&gt;
*[[Advanced_Turtle_Lumberjack_(tutorial)|Advanced Turtle Lumberjack]]&lt;br /&gt;
*[[Cobble_Generator|Cobblestone Generator]]&lt;br /&gt;
*[[Turtle_Stairbuilder_(tutorial)|Turtle Stairbuilder]]&lt;br /&gt;
&lt;br /&gt;
== External Tutorials/Guides ==&lt;br /&gt;
*[http://www.minecraftforum.net/topic/907632-mod-tutorial-computercraft-v12-very-basic-lua-tutorial-updated-1112/page__p__11556908#entry11556908 Onionnion's Basic Lua Tutorial]&lt;br /&gt;
*[http://www.computercraft.info/forums2/index.php?/topic/1516-ospullevent-what-is-it-and-how-is-it-useful/page__view__findpost__p__11156 Onionnion's os.pullEvent() Guide]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Talk:Os.setComputerLabel&amp;diff=1636</id>
		<title>Talk:Os.setComputerLabel</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Talk:Os.setComputerLabel&amp;diff=1636"/>
				<updated>2012-05-28T21:45:28Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Could anyone explain, why one would use this?--[[Special:Contributions/84.195.236.224|84.195.236.224]] 08:02, 25 May 2012 (UTC) Magmahunter&lt;br /&gt;
:Personally, I find it rather pointless. It labels the computer for if you destroy it and put it in your inventory, that seems to be all. Stops it stacking with other computers, too... [[User:My hat stinks|my_hat_stinks]] 21:45, 28 May 2012 (UTC)&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=User:My_hat_stinks&amp;diff=1632</id>
		<title>User:My hat stinks</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=User:My_hat_stinks&amp;diff=1632"/>
				<updated>2012-05-28T12:07:15Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Created page with &amp;quot;I am Hat.  I do as the situation requires.&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I am Hat.&lt;br /&gt;
&lt;br /&gt;
I do as the situation requires.&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Fs.list&amp;diff=1631</id>
		<title>Fs.list</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Fs.list&amp;diff=1631"/>
				<updated>2012-05-28T12:03:31Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{lowercase}}&lt;br /&gt;
{{Function&lt;br /&gt;
|name=fs.list&lt;br /&gt;
|args=[[string (type)|string]] path&lt;br /&gt;
|api=fs&lt;br /&gt;
|returns=[[table (type)|table]] list of files and folders in &amp;lt;var&amp;gt;path&amp;lt;/var&amp;gt;, which must be a directory&lt;br /&gt;
|desc=Returns a list of all the files contained in a directory, in table format&lt;br /&gt;
|examples=&lt;br /&gt;
{{Example&lt;br /&gt;
|desc=Displays a list of all files and folders in the root directory of a computer&lt;br /&gt;
|code=local FileList = fs.list(&amp;quot;&amp;quot;) --Table with all the files and directories available&lt;br /&gt;
 &lt;br /&gt;
 for _,file in ipairs( FileList ) do --Loop. Underscore because we don't use the key, ipairs so it's in order&lt;br /&gt;
   print( file ) --Print the file name&lt;br /&gt;
 end --End the loop&lt;br /&gt;
&lt;br /&gt;
|output=A list of all files and folders in the root directory as a table. Note that fs.list() could also be inserted directly into ipairs() or pairs()&lt;br /&gt;
}}&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Fs.list&amp;diff=1630</id>
		<title>Fs.list</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Fs.list&amp;diff=1630"/>
				<updated>2012-05-28T11:46:50Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{lowercase}}&lt;br /&gt;
{{Function&lt;br /&gt;
|name=fs.list&lt;br /&gt;
|args=[[string (type)|string]] path&lt;br /&gt;
|api=fs&lt;br /&gt;
|returns=[[table (type)|table]] list of files and folders in &amp;lt;var&amp;gt;path&amp;lt;/var&amp;gt;, which must be a directory&lt;br /&gt;
|desc=Returns a list of all the files contained in a directory, in table format&lt;br /&gt;
|examples=&lt;br /&gt;
{{Example&lt;br /&gt;
|desc=Displays a list of all files and folders in the root directory of a computer&lt;br /&gt;
|code=local FileList = fs.list(&amp;quot;&amp;quot;) --Table with all the files and directories available&lt;br /&gt;
 &lt;br /&gt;
 for _,file in ipairs( FileList ) do --Loop. Underscore because we don't use the key, ipairs so it's in order&lt;br /&gt;
   print( file ) --Print the file name&lt;br /&gt;
 end --End the loop&lt;br /&gt;
&lt;br /&gt;
|output=A list of all files and folders in the root directory as a table&lt;br /&gt;
}}&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Talk:Fs.list&amp;diff=1629</id>
		<title>Talk:Fs.list</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Talk:Fs.list&amp;diff=1629"/>
				<updated>2012-05-28T11:44:28Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Created page with &amp;quot;Zalerinian's edit to the example code makes the matter unnecessarily complicated, and has less desirable functionality. I'll fix it to something of a higher standard, more lik...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Zalerinian's edit to the example code makes the matter unnecessarily complicated, and has less desirable functionality. I'll fix it to something of a higher standard, more like what it previously was. [[User:My hat stinks|my_hat_stinks]] 11:44, 28 May 2012 (UTC)&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Talk:Disk&amp;diff=1611</id>
		<title>Talk:Disk</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Talk:Disk&amp;diff=1611"/>
				<updated>2012-05-24T12:05:47Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Should redirect to [http://computercraft.info/wiki/index.php?title=Floppy]&lt;br /&gt;
&lt;br /&gt;
Done. If more types of disk are added in future, this should be a disambiguation page. Also, sign your comments please. [[User:My hat stinks|my_hat_stinks]] 12:05, 24 May 2012 (UTC)&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Disk&amp;diff=1610</id>
		<title>Disk</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Disk&amp;diff=1610"/>
				<updated>2012-05-24T12:04:26Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Redirected page to Floppy Disk&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Floppy Disk]]&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Function_(type)&amp;diff=1594</id>
		<title>Function (type)</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Function_(type)&amp;diff=1594"/>
				<updated>2012-05-22T13:56:03Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: /* What are functions? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An introduction to functions&lt;br /&gt;
&lt;br /&gt;
== What are functions? ==&lt;br /&gt;
&lt;br /&gt;
Functions are a useful tool that helps simplify code, separating it by functionality and reducing repetitiveness. Understanding functions is key to becoming a successful coder. When a function is defined in lua, it will most likely look like this:&lt;br /&gt;
 function FunctionName()&lt;br /&gt;
   --Do stuff&lt;br /&gt;
 end&lt;br /&gt;
But may occasionally look more like a regular variable&lt;br /&gt;
 FunctionName = function()&lt;br /&gt;
   --Do stuff&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Both methods will yield the same result, so it's generally down to personal preference. Since functions are treated as normal variables, it is also possible to copy a function to a new variable&lt;br /&gt;
 NewFunctionName = OldFunctionName&lt;br /&gt;
Note that here, we aren't using the &amp;quot;()&amp;quot; present in the other methods. This is because we're using OldFunctionName as a variable, and not as a function.&lt;br /&gt;
&lt;br /&gt;
== How do I use functions? ==&lt;br /&gt;
&lt;br /&gt;
More than likely, if you've followed the &amp;quot;Hello World&amp;quot; tutorial, you have already used functions. Without standard in-built functions such as write() and print(), it would be impossible to interact with a user. Whenever you see brackets after a variable name, you know it's a function.&lt;br /&gt;
&lt;br /&gt;
For our first example, we will write a simple function that will use write()&lt;br /&gt;
 function MyFunction( Str )&lt;br /&gt;
   write( Str )&lt;br /&gt;
 end&lt;br /&gt;
 MyFunction( &amp;quot;I am writing text to the screen!\n&amp;quot; )&lt;br /&gt;
&lt;br /&gt;
If you have successfully written and executed this script, it should write &amp;quot;I am writing text to the screen!&amp;quot; on the screen. Notice how the function has a variable name in the brackets. This is called an &amp;quot;argument&amp;quot;, and will likely be crucial to your functions later. There can be any number of arguments, separated by commas, and arguments can be any type of variable, including other functions.&lt;br /&gt;
&lt;br /&gt;
Add the following line to your code&lt;br /&gt;
 MyFunction( true )&lt;br /&gt;
This will pass a boolean value to your function, and it will error as it reaches the write(), which can't use a boolean value. To fix this, we'll need to validate what type of variable is being given. Try adding another line so your code looks like this:&lt;br /&gt;
 function MyFunction( Str )&lt;br /&gt;
   if type(Str) ~= &amp;quot;string&amp;quot; then return end&lt;br /&gt;
   write( Str )&lt;br /&gt;
 end&lt;br /&gt;
 MyFunction( &amp;quot;I am writing text to the screen!\n&amp;quot; )&lt;br /&gt;
 MyFunction( true )&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;type&amp;quot; functions will give you a string with the type of variable you give it. In this case, if the variable is not a string, it will run &amp;quot;return&amp;quot;. Return will be described in more detail later in this tutorial, but for now we only need to know it ends the function, so any code after it will not be run. If you run your script now, you will see that there will be no error when it tries to use the boolean value. In fact, it will produce nothing at all, which may not be desirable. Edit the return line so it reads as follows&lt;br /&gt;
 if type(Str) ~= &amp;quot;string&amp;quot; then write(&amp;quot;Bad argument #1 to MyFuction: String expected, got &amp;quot;..type(Str)..&amp;quot;!\n&amp;quot;) return end&lt;br /&gt;
If you run the code again, you will find it now gives an error when it reaches the boolean. The difference between this and the usual error() command called for a real error, is that this won't exit your code, and any line afterwards will still run as normal.&lt;br /&gt;
&lt;br /&gt;
All this script really does is give a new name to the write() function, so there is a simpler way to do it. Before reading the following code, see if you can use your current knowledge to work it out for yourself.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The simplest way to get a new name for a function is as follows.&lt;br /&gt;
 MyFunction = write&lt;br /&gt;
This means that any call to MyFunction() will act as write() did. Note that any changes to write() ''after'' this line will not edit MyFunction, which is why this method is often used to back up a built-in function before it's overwritten. As an example, someone may want to disable the write() function, but still have a way to use it when necessary.&lt;br /&gt;
 MyFunction = write&lt;br /&gt;
 write = function() MyFunction(&amp;quot;This function has been disabled!\n&amp;quot;) end&lt;br /&gt;
This will write &amp;quot;This function has been disabled!&amp;quot; every time someone tries to use write()&lt;br /&gt;
&lt;br /&gt;
== Return ==&lt;br /&gt;
&lt;br /&gt;
Sometimes you will want a function to give a value back when it is done. This is the purpose of &amp;quot;return&amp;quot;, it will return one or more values and end the function.&lt;br /&gt;
 local function RandomNumber()&lt;br /&gt;
   local rand = math.random(0,10)&lt;br /&gt;
   return rand&lt;br /&gt;
 end&lt;br /&gt;
 local Num = RandomNumber()&lt;br /&gt;
&lt;br /&gt;
This will set Num to a random number between 0 and 1. Notice how this time we are including the () for the function, this means we're calling the function rather than using it as a variable.&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Tutorials&amp;diff=1593</id>
		<title>Tutorials</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Tutorials&amp;diff=1593"/>
				<updated>2012-05-22T12:41:43Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: /* Basic Tutorials */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As some tutorials might not be listed here, you can also browse the [[:Category:Tutorials|tutorials category]].&lt;br /&gt;
&lt;br /&gt;
== Before you begin ==&lt;br /&gt;
It is recommended that you read these pages before you begin working with ComputerCraft.&lt;br /&gt;
*[[Getting Started]]&lt;br /&gt;
*[[CraftOS Shell | Shell Commands]]&lt;br /&gt;
&lt;br /&gt;
== Basic Tutorials ==&lt;br /&gt;
These tutorials are designed to be used in the order shown, each tutorial will build on the previous ones.&lt;br /&gt;
=== Introduction to Coding ===&lt;br /&gt;
*[[Hello_World_Tutorial|Hello World!]]&lt;br /&gt;
*[[Variables]]&lt;br /&gt;
*[[Conditional_statements|If, Then, Else]]&lt;br /&gt;
*[[Functions]]&lt;br /&gt;
&lt;br /&gt;
== Exemplar Programs ==&lt;br /&gt;
These pages guide you through programs created by other users. They are not necessarily well-coded, but can be useful as a loose guide.&lt;br /&gt;
=== Programming &amp;amp; Wiring ===&lt;br /&gt;
*[[Making_a_Delay_function|Making a Delay (timer) function]]&lt;br /&gt;
*[[Guess_The_Number_(tutorial)|Guess the Number]]&lt;br /&gt;
*[[Making_a_Password_Protected_Door|Password Protected Door]]&lt;br /&gt;
*[[Making_an_API_(tutorial)|Programming an API]]&lt;br /&gt;
*[[Startup|Running script automatically at boot with Startup]]&lt;br /&gt;
*[[Raw key events| Detecting specific keys (such as the arrow keys)]]&lt;br /&gt;
*[[Receiving a rednet message through os.pullEvent()|Receiving a rednet message through os.pullEvent()]]&lt;br /&gt;
*[[Calculator_Tutorial]]&lt;br /&gt;
=== Turtles ===&lt;br /&gt;
The nice little robots that do the hard work for you.&lt;br /&gt;
*[[Turtle_Tutorial|Turtles!]]&lt;br /&gt;
*[[Turtle_Lumberjack_(tutorial)|Turtle Lumberjack]]&lt;br /&gt;
*[[Advanced_Turtle_Lumberjack_(tutorial)|Advanced Turtle Lumberjack]]&lt;br /&gt;
*[[Cobble_Generator|Cobblestone Generator]]&lt;br /&gt;
*[[Turtle_Stairbuilder_(tutorial)|Turtle Stairbuilder]]&lt;br /&gt;
&lt;br /&gt;
== External Tutorials/Guides ==&lt;br /&gt;
*[http://www.minecraftforum.net/topic/907632-mod-tutorial-computercraft-v12-very-basic-lua-tutorial-updated-1112/page__p__11556908#entry11556908 Onionnion's Basic Lua Tutorial]&lt;br /&gt;
*[http://www.computercraft.info/forums2/index.php?/topic/1516-ospullevent-what-is-it-and-how-is-it-useful/page__view__findpost__p__11156 Onionnion's os.pullEvent() Guide]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Function_(type)&amp;diff=1591</id>
		<title>Function (type)</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Function_(type)&amp;diff=1591"/>
				<updated>2012-05-22T12:41:10Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: moved Function to Functions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An introduction to functions&lt;br /&gt;
&lt;br /&gt;
== What are functions? ==&lt;br /&gt;
&lt;br /&gt;
Functions are a useful tool, understanding and using functions is key to becoming a successful coder. They help to simplify code, separating it by functionality and reducing repetitiveness. When a function is defined in lua, it will most likely look like this:&lt;br /&gt;
 function FunctionName()&lt;br /&gt;
   --Do stuff&lt;br /&gt;
 end&lt;br /&gt;
But may occasionally look more like a regular variable&lt;br /&gt;
 FunctionName = function()&lt;br /&gt;
   --Do stuff&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Both methods will yield the same result, so it's generally down to personal preference. Since functions are treated as normal variables, it is also possible to copy a function to a new variable&lt;br /&gt;
 NewFunctionName = OldFunctionName&lt;br /&gt;
Note that here, we aren't using the &amp;quot;()&amp;quot; present in the other methods. This is because we're using OldFunctionName as a variable, and not as a function.&lt;br /&gt;
&lt;br /&gt;
== How do I use functions? ==&lt;br /&gt;
&lt;br /&gt;
More than likely, if you've followed the &amp;quot;Hello World&amp;quot; tutorial, you have already used functions. Without standard in-built functions such as write() and print(), it would be impossible to interact with a user. Whenever you see brackets after a variable name, you know it's a function.&lt;br /&gt;
&lt;br /&gt;
For our first example, we will write a simple function that will use write()&lt;br /&gt;
 function MyFunction( Str )&lt;br /&gt;
   write( Str )&lt;br /&gt;
 end&lt;br /&gt;
 MyFunction( &amp;quot;I am writing text to the screen!\n&amp;quot; )&lt;br /&gt;
&lt;br /&gt;
If you have successfully written and executed this script, it should write &amp;quot;I am writing text to the screen!&amp;quot; on the screen. Notice how the function has a variable name in the brackets. This is called an &amp;quot;argument&amp;quot;, and will likely be crucial to your functions later. There can be any number of arguments, separated by commas, and arguments can be any type of variable, including other functions.&lt;br /&gt;
&lt;br /&gt;
Add the following line to your code&lt;br /&gt;
 MyFunction( true )&lt;br /&gt;
This will pass a boolean value to your function, and it will error as it reaches the write(), which can't use a boolean value. To fix this, we'll need to validate what type of variable is being given. Try adding another line so your code looks like this:&lt;br /&gt;
 function MyFunction( Str )&lt;br /&gt;
   if type(Str) ~= &amp;quot;string&amp;quot; then return end&lt;br /&gt;
   write( Str )&lt;br /&gt;
 end&lt;br /&gt;
 MyFunction( &amp;quot;I am writing text to the screen!\n&amp;quot; )&lt;br /&gt;
 MyFunction( true )&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;type&amp;quot; functions will give you a string with the type of variable you give it. In this case, if the variable is not a string, it will run &amp;quot;return&amp;quot;. Return will be described in more detail later in this tutorial, but for now we only need to know it ends the function, so any code after it will not be run. If you run your script now, you will see that there will be no error when it tries to use the boolean value. In fact, it will produce nothing at all, which may not be desirable. Edit the return line so it reads as follows&lt;br /&gt;
 if type(Str) ~= &amp;quot;string&amp;quot; then write(&amp;quot;Bad argument #1 to MyFuction: String expected, got &amp;quot;..type(Str)..&amp;quot;!\n&amp;quot;) return end&lt;br /&gt;
If you run the code again, you will find it now gives an error when it reaches the boolean. The difference between this and the usual error() command called for a real error, is that this won't exit your code, and any line afterwards will still run as normal.&lt;br /&gt;
&lt;br /&gt;
All this script really does is give a new name to the write() function, so there is a simpler way to do it. Before reading the following code, see if you can use your current knowledge to work it out for yourself.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The simplest way to get a new name for a function is as follows.&lt;br /&gt;
 MyFunction = write&lt;br /&gt;
This means that any call to MyFunction() will act as write() did. Note that any changes to write() ''after'' this line will not edit MyFunction, which is why this method is often used to back up a built-in function before it's overwritten. As an example, someone may want to disable the write() function, but still have a way to use it when necessary.&lt;br /&gt;
 MyFunction = write&lt;br /&gt;
 write = function() MyFunction(&amp;quot;This function has been disabled!\n&amp;quot;) end&lt;br /&gt;
This will write &amp;quot;This function has been disabled!&amp;quot; every time someone tries to use write()&lt;br /&gt;
&lt;br /&gt;
== Return ==&lt;br /&gt;
&lt;br /&gt;
Sometimes you will want a function to give a value back when it is done. This is the purpose of &amp;quot;return&amp;quot;, it will return one or more values and end the function.&lt;br /&gt;
 local function RandomNumber()&lt;br /&gt;
   local rand = math.random(0,10)&lt;br /&gt;
   return rand&lt;br /&gt;
 end&lt;br /&gt;
 local Num = RandomNumber()&lt;br /&gt;
&lt;br /&gt;
This will set Num to a random number between 0 and 1. Notice how this time we are including the () for the function, this means we're calling the function rather than using it as a variable.&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Function_(type)&amp;diff=1590</id>
		<title>Function (type)</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Function_(type)&amp;diff=1590"/>
				<updated>2012-05-22T12:39:21Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Created page with &amp;quot;An introduction to functions  == What are functions? ==  Functions are a useful tool, understanding and using functions is key to becoming a successful coder. They help to sim...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An introduction to functions&lt;br /&gt;
&lt;br /&gt;
== What are functions? ==&lt;br /&gt;
&lt;br /&gt;
Functions are a useful tool, understanding and using functions is key to becoming a successful coder. They help to simplify code, separating it by functionality and reducing repetitiveness. When a function is defined in lua, it will most likely look like this:&lt;br /&gt;
 function FunctionName()&lt;br /&gt;
   --Do stuff&lt;br /&gt;
 end&lt;br /&gt;
But may occasionally look more like a regular variable&lt;br /&gt;
 FunctionName = function()&lt;br /&gt;
   --Do stuff&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
Both methods will yield the same result, so it's generally down to personal preference. Since functions are treated as normal variables, it is also possible to copy a function to a new variable&lt;br /&gt;
 NewFunctionName = OldFunctionName&lt;br /&gt;
Note that here, we aren't using the &amp;quot;()&amp;quot; present in the other methods. This is because we're using OldFunctionName as a variable, and not as a function.&lt;br /&gt;
&lt;br /&gt;
== How do I use functions? ==&lt;br /&gt;
&lt;br /&gt;
More than likely, if you've followed the &amp;quot;Hello World&amp;quot; tutorial, you have already used functions. Without standard in-built functions such as write() and print(), it would be impossible to interact with a user. Whenever you see brackets after a variable name, you know it's a function.&lt;br /&gt;
&lt;br /&gt;
For our first example, we will write a simple function that will use write()&lt;br /&gt;
 function MyFunction( Str )&lt;br /&gt;
   write( Str )&lt;br /&gt;
 end&lt;br /&gt;
 MyFunction( &amp;quot;I am writing text to the screen!\n&amp;quot; )&lt;br /&gt;
&lt;br /&gt;
If you have successfully written and executed this script, it should write &amp;quot;I am writing text to the screen!&amp;quot; on the screen. Notice how the function has a variable name in the brackets. This is called an &amp;quot;argument&amp;quot;, and will likely be crucial to your functions later. There can be any number of arguments, separated by commas, and arguments can be any type of variable, including other functions.&lt;br /&gt;
&lt;br /&gt;
Add the following line to your code&lt;br /&gt;
 MyFunction( true )&lt;br /&gt;
This will pass a boolean value to your function, and it will error as it reaches the write(), which can't use a boolean value. To fix this, we'll need to validate what type of variable is being given. Try adding another line so your code looks like this:&lt;br /&gt;
 function MyFunction( Str )&lt;br /&gt;
   if type(Str) ~= &amp;quot;string&amp;quot; then return end&lt;br /&gt;
   write( Str )&lt;br /&gt;
 end&lt;br /&gt;
 MyFunction( &amp;quot;I am writing text to the screen!\n&amp;quot; )&lt;br /&gt;
 MyFunction( true )&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;type&amp;quot; functions will give you a string with the type of variable you give it. In this case, if the variable is not a string, it will run &amp;quot;return&amp;quot;. Return will be described in more detail later in this tutorial, but for now we only need to know it ends the function, so any code after it will not be run. If you run your script now, you will see that there will be no error when it tries to use the boolean value. In fact, it will produce nothing at all, which may not be desirable. Edit the return line so it reads as follows&lt;br /&gt;
 if type(Str) ~= &amp;quot;string&amp;quot; then write(&amp;quot;Bad argument #1 to MyFuction: String expected, got &amp;quot;..type(Str)..&amp;quot;!\n&amp;quot;) return end&lt;br /&gt;
If you run the code again, you will find it now gives an error when it reaches the boolean. The difference between this and the usual error() command called for a real error, is that this won't exit your code, and any line afterwards will still run as normal.&lt;br /&gt;
&lt;br /&gt;
All this script really does is give a new name to the write() function, so there is a simpler way to do it. Before reading the following code, see if you can use your current knowledge to work it out for yourself.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The simplest way to get a new name for a function is as follows.&lt;br /&gt;
 MyFunction = write&lt;br /&gt;
This means that any call to MyFunction() will act as write() did. Note that any changes to write() ''after'' this line will not edit MyFunction, which is why this method is often used to back up a built-in function before it's overwritten. As an example, someone may want to disable the write() function, but still have a way to use it when necessary.&lt;br /&gt;
 MyFunction = write&lt;br /&gt;
 write = function() MyFunction(&amp;quot;This function has been disabled!\n&amp;quot;) end&lt;br /&gt;
This will write &amp;quot;This function has been disabled!&amp;quot; every time someone tries to use write()&lt;br /&gt;
&lt;br /&gt;
== Return ==&lt;br /&gt;
&lt;br /&gt;
Sometimes you will want a function to give a value back when it is done. This is the purpose of &amp;quot;return&amp;quot;, it will return one or more values and end the function.&lt;br /&gt;
 local function RandomNumber()&lt;br /&gt;
   local rand = math.random(0,10)&lt;br /&gt;
   return rand&lt;br /&gt;
 end&lt;br /&gt;
 local Num = RandomNumber()&lt;br /&gt;
&lt;br /&gt;
This will set Num to a random number between 0 and 1. Notice how this time we are including the () for the function, this means we're calling the function rather than using it as a variable.&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Variables&amp;diff=1589</id>
		<title>Variables</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Variables&amp;diff=1589"/>
				<updated>2012-05-22T09:06:31Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: /* What do variables look like? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Tutorials]]&lt;br /&gt;
This is a tutorial page for Variables and their function.&lt;br /&gt;
&lt;br /&gt;
== What are Variables? ==&lt;br /&gt;
&lt;br /&gt;
Variables are one of the fundamental building blocks of all coding languages. Variables are just as they sound, they can store a changeable value.&lt;br /&gt;
&lt;br /&gt;
== What do variables look like? ==&lt;br /&gt;
&lt;br /&gt;
Variables will usually be defined near the start of a script or function (Functions will be taught in a later tutorial), as this will make them easy to edit later if required. Variables can be defined in a number of different ways, reliant on the type of data that is being stored.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; String values&lt;br /&gt;
String variables can store any text or &amp;quot;string&amp;quot; that you will use in your script. Strings can be defined as follows&lt;br /&gt;
 local Text = 'This is a string!'&lt;br /&gt;
 local MoreText = &amp;quot;This is also a string!&amp;quot;&lt;br /&gt;
String values have the unique ability to be concatenated (One added to the end of the other). To do this, simply enter a &amp;quot;..&amp;quot; between the two strings or variables.&lt;br /&gt;
 local Start = &amp;quot;This is&amp;quot;&lt;br /&gt;
 local Middle = &amp;quot; all part of &amp;quot;&lt;br /&gt;
 local End = &amp;quot;one sentence!\n&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 Start = Start..Middle&lt;br /&gt;
 &lt;br /&gt;
 write(Start..End)&lt;br /&gt;
This will write &amp;quot;This is all part of one sentence!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Number values&lt;br /&gt;
Number variables can store any number used in the script, as well as perform calculations with them.&lt;br /&gt;
Numbers can be defined as follows&lt;br /&gt;
 local Number = 1&lt;br /&gt;
 local AnotherNumber = 2&lt;br /&gt;
Lua supports the following mathematical functions:&lt;br /&gt;
*Addition (+) ''1+1=2''&lt;br /&gt;
*Subtraction (-) ''2-1=1''&lt;br /&gt;
*Multiplication (*) ''2*2 =4''&lt;br /&gt;
*Division (/) ''2/2 =1''&lt;br /&gt;
*Power (^) ''2^3 =8''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Boolean values&lt;br /&gt;
Boolean variables are simply a &amp;quot;True or False?&amp;quot; variable. They can be either true or false, but nothing else. Boolean values are usually used for conditional statements, which will be covered in a later tutorial.&lt;br /&gt;
Boolean variables can be defined as follows&lt;br /&gt;
 local Bool = true&lt;br /&gt;
 local Bool2 = false&lt;br /&gt;
Note that &amp;quot;true&amp;quot; and &amp;quot;false&amp;quot; are case sensitive.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Nil values&lt;br /&gt;
Nil values are values that are currently storing nothing. Usually you will not explicitly set a variable to nil, as it acts similar to a &amp;quot;false&amp;quot; boolean. All variables are nil by default.&lt;br /&gt;
 local Variable = nil&lt;br /&gt;
Note that &amp;quot;nil&amp;quot; is case sensitive&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Table values&lt;br /&gt;
Table variables are variables that can store any other variables, including more tables. They will be described in more depth in a later tutorial.&lt;br /&gt;
Tables can be defined as follows&lt;br /&gt;
 local EmptyTable = {}&lt;br /&gt;
 local Table = {1,2,3,4}&lt;br /&gt;
 local AnotherTable = {&amp;quot;This table&amp;quot;, &amp;quot;Contains&amp;quot;, 3, {&amp;quot;Types of variables!&amp;quot;} }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Function values&lt;br /&gt;
Although not often considered variables, Lua functions can act the same way as other more standard variables. Functions will be described in more detail in a later tutorial.&lt;br /&gt;
functions can be defined as follows&lt;br /&gt;
  local DoStuff = function() end&lt;br /&gt;
  local function AnotherFunction() end&lt;br /&gt;
  &lt;br /&gt;
  local DoStuff2 = function()&lt;br /&gt;
    write(&amp;quot;Function!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
  local function AnotherFunction2()&lt;br /&gt;
    write(&amp;quot;Another function!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
Function and table variables are usually defined over multiple lines due to the length of them. In Lua, a new line does not mark any functionality and is used purely for readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unlike many other languages, Lua allows for variable's data types to be changed as you go, easily overwriting, for example, a string with a number.&lt;br /&gt;
  local Variable = &amp;quot;String!&amp;quot; --The variable is a string&lt;br /&gt;
  Variable = 1 --The variable is now a number&lt;br /&gt;
&lt;br /&gt;
== What is &amp;quot;local&amp;quot; and why is it useful? ==&lt;br /&gt;
You may have noticed the use of &amp;quot;local&amp;quot; in the above declarations. &amp;quot;local&amp;quot; simply states that the variable being defined should only be used in this script or function. You only need to write local for the first time you set a variable, then it will assume every other time you use the variable afterwords it is the local variable. If you use or set a variable without using local, it will try and use or set a global variable which can be used and modified by other scripts.&lt;br /&gt;
&lt;br /&gt;
Although it likely won't be an issue when you are using ComputerCraft, it is advisable to use local variables and functions when possible, so they will not be unintentionally edited by other functions or scripts.&lt;br /&gt;
&lt;br /&gt;
== Multiple assignments ==&lt;br /&gt;
Variables don't necessarily need to be defined one at a time, it is possible to assign multiple values in one operation through the use of commas.&lt;br /&gt;
  local Var1, Var2 = &amp;quot;One&amp;quot;, &amp;quot;Two&amp;quot;&lt;br /&gt;
  write( Var1..Var2..&amp;quot;\n&amp;quot; )&lt;br /&gt;
This script will successfully assign the values &amp;quot;One&amp;quot; and &amp;quot;Two&amp;quot;, then write &amp;quot;OneTwo&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==What have we learned?==&lt;br /&gt;
*Variables can store values&lt;br /&gt;
*Variables store different types of values&lt;br /&gt;
*Variables can be defined in different ways&lt;br /&gt;
*An overview of what different variable types do&lt;br /&gt;
*Use &amp;quot;local&amp;quot; to use variables locally&lt;br /&gt;
*Muitlple values may be assigned at once&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Turtle&amp;diff=1588</id>
		<title>Turtle</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Turtle&amp;diff=1588"/>
				<updated>2012-05-21T19:20:28Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Undo revision 1587 by 81.155.48.23 (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Turtles''' are essentially robots, and were added in the 1.3 update. They run an OS (like the [[Console|consoles]]) named [[TurtleOS]]. They have the ability to place, break and detect blocks, move around and drop items in their inventory. The programs they run are stored on [[Floppy Disk|floppy disks]].&lt;br /&gt;
&lt;br /&gt;
Turtles are submersible and lavaproof. As such, they are extremely useful for mining near bedrock, where heavy lava flows can prevent access to diamonds and other rare finds.&lt;br /&gt;
&lt;br /&gt;
If you would like to know more about how to program them, have a look at the [[Turtle (API)|Turtle API]].&lt;br /&gt;
&lt;br /&gt;
==Floppy Disks==&lt;br /&gt;
Turtles do not have a built-in floppy drive. As such they need a floppy drive placed next to them to access disks.&lt;br /&gt;
&lt;br /&gt;
==Power source==&lt;br /&gt;
Turtles have been equipped with a state of the art AWESOME FANTASTIC AMAZING quantum ionizing engine. This means that, once given fuel (the redstone used to craft them), they do not need to be re-charged, nor do any fuel cells need to be replaced, likewise they don't need to have external power directed to them either.&lt;br /&gt;
&lt;br /&gt;
==Crafting==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|+'''Crafting ingredients'''&lt;br /&gt;
|-&lt;br /&gt;
|Turtle&lt;br /&gt;
|{{Crafting grid&lt;br /&gt;
 |A1=iron_ingot |B1=iron_ingot |C1=iron_ingot&lt;br /&gt;
 |A2=iron_ingot |B2=console    |C2=iron_ingot&lt;br /&gt;
 |A3=iron_ingot |B3=chest      |C3=iron_ingot&lt;br /&gt;
 |Output=turtle&lt;br /&gt;
 }}&lt;br /&gt;
|-&lt;br /&gt;
|Mining Turtle&lt;br /&gt;
|{{Crafting grid&lt;br /&gt;
 |A2=turtle |B2=diamond_pickaxe&lt;br /&gt;
 |Output=mining_turtle&lt;br /&gt;
 }}&lt;br /&gt;
|-&lt;br /&gt;
|Wireless Turtle&lt;br /&gt;
|{{Crafting grid&lt;br /&gt;
 |A2=turtle |B2=modem&lt;br /&gt;
 |Output=wireless_turtle&lt;br /&gt;
 }}&lt;br /&gt;
|-&lt;br /&gt;
|Wireless Mining Turtle&lt;br /&gt;
|{{Crafting grid&lt;br /&gt;
 |A1=modem |B1=turtle |C1=diamond_pickaxe&lt;br /&gt;
 |Output=wireless_mining_turtle&lt;br /&gt;
 }}&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Blocks]]&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Monitor&amp;diff=1586</id>
		<title>Monitor</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Monitor&amp;diff=1586"/>
				<updated>2012-05-20T16:25:27Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Undo revision 1584 by 86.8.98.85 (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The '''Screen''' is a block that can display text on its front side. When several screen blocks are placed on the same plane, it will form a single monitor.&lt;br /&gt;
&lt;br /&gt;
===Recipe===&lt;br /&gt;
{{Crafting grid&lt;br /&gt;
 |A1=stone |B1=stone      |C1=stone&lt;br /&gt;
 |A2=stone |B2=glass_pane |C2=stone&lt;br /&gt;
 |A3=stone |B3=stone      |C3=stone&lt;br /&gt;
 |Output=screen&lt;br /&gt;
 }}&lt;br /&gt;
[[Category:Blocks]]&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Talk:Conditional_statements&amp;diff=1575</id>
		<title>Talk:Conditional statements</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Talk:Conditional_statements&amp;diff=1575"/>
				<updated>2012-05-19T18:49:44Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Created page with &amp;quot;Seems a little messy to me, but all the information should be there. ~~~~&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Seems a little messy to me, but all the information should be there. [[User:My hat stinks|my_hat_stinks]] 18:49, 19 May 2012 (UTC)&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Tutorials&amp;diff=1574</id>
		<title>Tutorials</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Tutorials&amp;diff=1574"/>
				<updated>2012-05-19T18:48:48Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: /* Introduction to Coding */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As some tutorials might not be listed here, you can also browse the [[:Category:Tutorials|tutorials category]].&lt;br /&gt;
&lt;br /&gt;
== Before you begin ==&lt;br /&gt;
It is recommended that you read these pages before you begin working with ComputerCraft.&lt;br /&gt;
*[[Getting Started]]&lt;br /&gt;
*[[CraftOS Shell | Shell Commands]]&lt;br /&gt;
&lt;br /&gt;
== Basic Tutorials ==&lt;br /&gt;
These tutorials are designed to be used in the order shown, each tutorial will build on the previous ones.&lt;br /&gt;
=== Introduction to Coding ===&lt;br /&gt;
*[[Hello_World_Tutorial|Hello World!]]&lt;br /&gt;
*[[Variables]]&lt;br /&gt;
*[[Conditional_statements|If, Then, Else]]&lt;br /&gt;
&lt;br /&gt;
== Exemplar Programs ==&lt;br /&gt;
These pages guide you through programs created by other users. They are not necessarily well-coded, but can be useful as a loose guide.&lt;br /&gt;
=== Programming &amp;amp; Wiring ===&lt;br /&gt;
*[[Making_a_Delay_function|Making a Delay (timer) function]]&lt;br /&gt;
*[[Guess_The_Number_(tutorial)|Guess the Number]]&lt;br /&gt;
*[[Making_a_Password_Protected_Door|Password Protected Door]]&lt;br /&gt;
*[[Making_an_API_(tutorial)|Programming an API]]&lt;br /&gt;
*[[Startup|Running script automatically at boot with Startup]]&lt;br /&gt;
*[[Raw key events| Detecting specific keys (such as the arrow keys)]]&lt;br /&gt;
*[[Receiving a rednet message through os.pullEvent()|Receiving a rednet message through os.pullEvent()]]&lt;br /&gt;
*[[Calculator_Tutorial]]&lt;br /&gt;
=== Turtles ===&lt;br /&gt;
The nice little robots that do the hard work for you.&lt;br /&gt;
*[[Turtle_Tutorial|Turtles!]]&lt;br /&gt;
*[[Turtle_Lumberjack_(tutorial)|Turtle Lumberjack]]&lt;br /&gt;
*[[Advanced_Turtle_Lumberjack_(tutorial)|Advanced Turtle Lumberjack]]&lt;br /&gt;
*[[Cobble_Generator|Cobblestone Generator]]&lt;br /&gt;
*[[Turtle_Stairbuilder_(tutorial)|Turtle Stairbuilder]]&lt;br /&gt;
&lt;br /&gt;
== External Tutorials/Guides ==&lt;br /&gt;
*[http://www.minecraftforum.net/topic/907632-mod-tutorial-computercraft-v12-very-basic-lua-tutorial-updated-1112/page__p__11556908#entry11556908 Onionnion's Basic Lua Tutorial]&lt;br /&gt;
*[http://www.computercraft.info/forums2/index.php?/topic/1516-ospullevent-what-is-it-and-how-is-it-useful/page__view__findpost__p__11156 Onionnion's os.pullEvent() Guide]&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Conditional_statements&amp;diff=1573</id>
		<title>Conditional statements</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Conditional_statements&amp;diff=1573"/>
				<updated>2012-05-19T18:48:11Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Tutorials]]&lt;br /&gt;
This is a tutorial will teach you how to make your script react to different situations.&lt;br /&gt;
&lt;br /&gt;
== The If statement ==&lt;br /&gt;
&lt;br /&gt;
Conditional statements are one of the fundamental building blocks for any coding languages. They are just as they sound, if a condition is met then a block of code will run. The simplest form of conditional statement available in Lua is the &amp;quot;If&amp;quot; statement, which indicates that if one or more conditions are met, the following block of code will run. If statements take the following format&lt;br /&gt;
  local Variable = 1&lt;br /&gt;
  if Variable==1 then&lt;br /&gt;
    write(&amp;quot;The variable is 1!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
  if Variable==2 then&lt;br /&gt;
    write(&amp;quot;The variable is 2!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This script will simply output the text &amp;quot;The variable is 1!&amp;quot;. The &amp;quot;==&amp;quot; operator simply means &amp;quot;is equal to&amp;quot;, so the line reads along the lines of &amp;quot;If Variable is equal to 1, then do this&amp;quot;. &amp;quot;end&amp;quot; marks the end of the code block, and anything after it is run normally regardless of whether the conditions were met.&lt;br /&gt;
&lt;br /&gt;
Brackets may optionally be used around conditions, although it is not necessary unless you want to control the order of a calculation.&lt;br /&gt;
&lt;br /&gt;
Note that since lua disregards new lines, it would be equally acceptable to write the following&lt;br /&gt;
 if Variable==1 then write(&amp;quot;The variable is 1!\n&amp;quot;) end&lt;br /&gt;
However, this method is generally less readable and not commonly used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lua determines whether an if statement passes by using the boolean values returned by the condition, so it would be possible but unnecessary to enter a boolean as the condition as follows&lt;br /&gt;
 if true then write(&amp;quot;This will always write!\n&amp;quot;)&lt;br /&gt;
 if false then write(&amp;quot;This will never write!\n&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
== Available conditions ==&lt;br /&gt;
There are a number of different conditions that can be used to make the &lt;br /&gt;
&lt;br /&gt;
;Is equal to&lt;br /&gt;
  if Variable == Variable2 then&lt;br /&gt;
    --Do stuff&lt;br /&gt;
  end&lt;br /&gt;
The &amp;quot;==&amp;quot; condition is the most basic operator, simply comparing two values to see if they are the same. If both values are the same, the condition is met and the if statement passes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Is not equal to&lt;br /&gt;
  if Variable ~= Variable2 then&lt;br /&gt;
    --Do stuff&lt;br /&gt;
  end&lt;br /&gt;
The &amp;quot;~=&amp;quot; condition compares two values to see if they are the same, and if they are ''not'' the same, the condition is met and the if statement passes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Greater than&lt;br /&gt;
  if Number &amp;gt; Number2 then&lt;br /&gt;
    --Do stuff&lt;br /&gt;
  end&lt;br /&gt;
The &amp;quot;&amp;gt;&amp;quot; condition compares two number values, and if the first is greater than the second, the condition is met and the if statement passes. The &amp;quot;&amp;gt;=&amp;quot; (Greater than or equal to) operator acts as both the &amp;quot;greater than&amp;quot; and the &amp;quot;equal to&amp;quot; conditions, meaning the condition is met if either the first number is equal to the second, or the first number is greater than the second.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Less than&lt;br /&gt;
  if Number &amp;lt; Number2 then&lt;br /&gt;
    --Do stuff&lt;br /&gt;
  end&lt;br /&gt;
The &amp;quot;&amp;lt;&amp;quot; condition compares two number values, and if the first is lower than the second, the condition is met and the if statement passes. The &amp;quot;&amp;lt;=&amp;quot; (Less than or equal to) operator acts as a combination of the &amp;quot;less than&amp;quot; and the &amp;quot;equal to&amp;quot; conditions.&lt;br /&gt;
&lt;br /&gt;
=== And, Or, Not ===&lt;br /&gt;
&lt;br /&gt;
Sometimes it is desirable to combine conditions. Although it is possible to use multiple if statements, or ifs inside ifs, it is a best practice to use &amp;quot;and&amp;quot; and &amp;quot;or&amp;quot; if possible.&lt;br /&gt;
&lt;br /&gt;
;And&lt;br /&gt;
 local Num1,Num2,Num3 = 1,2,3&lt;br /&gt;
 &lt;br /&gt;
 --Multiple if&lt;br /&gt;
 if Num1 &amp;gt; Num2 then&lt;br /&gt;
   if Num2 &amp;lt; Num3 then&lt;br /&gt;
     write(&amp;quot;Condition is true!&amp;quot;)&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 --Using And&lt;br /&gt;
 if (Num1&amp;gt;Num2) and (Num2&amp;lt;Num3) then&lt;br /&gt;
   write(&amp;quot;Condition is true!&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;and&amp;quot; operator means that both conditions must match before the statement passes. If either side fails, the whole condition is false. Note that if the left side fails, the right side is ignored, so if you have a critical function it should be on the left of the &amp;quot;and&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
;Or&lt;br /&gt;
 local Num1,Num2,Num3 = 1,2,3&lt;br /&gt;
 &lt;br /&gt;
 --Multiple if&lt;br /&gt;
 if Num1 &amp;gt; Num2 then&lt;br /&gt;
   write(&amp;quot;Condition is true!&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
 if Num2 &amp;lt; Num3 then&lt;br /&gt;
   write(&amp;quot;Condition is true!&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 --Using Or&lt;br /&gt;
 if (Num1&amp;gt;Num2) or (Num2&amp;lt;Num3) then&lt;br /&gt;
   write(&amp;quot;Condition is true!&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;or&amp;quot; operator means that if either condition matches the statement passes. This means that if either the left side, the right side, or both pass, the statement is true. Note that if the left side passes, the right side is ignored, so if you have a critical function it should be on the left of the &amp;quot;or&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
;Not&lt;br /&gt;
 local Num1,Num2,Num3 = 1,2,3&lt;br /&gt;
 &lt;br /&gt;
 if (Num1 &amp;lt; Num2) and not (Num1 &amp;gt; Num3) then&lt;br /&gt;
   write(&amp;quot;Condition is true!&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
While the &amp;quot;not&amp;quot; statement is rarely a necessity, it can be used to reverse a value from &amp;quot;true&amp;quot; to &amp;quot;false&amp;quot; or vice versa.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In some situations, it may be preferable not to use these statements as code will run before the second condition needs to be assessed, such as as follows&lt;br /&gt;
 local Num1,Num2 = 1,2&lt;br /&gt;
 &lt;br /&gt;
 --And should not be used here&lt;br /&gt;
 if Num1&amp;gt;Num2 then&lt;br /&gt;
   local Num3 = 3&lt;br /&gt;
   &lt;br /&gt;
   if Num3&amp;gt;Num2 then write(&amp;quot;Text!\n&amp;quot;) end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== The Else statement ==&lt;br /&gt;
&lt;br /&gt;
It is common that you may want to run some code on the failure of the condition. If this is the case, it may be achieved through the use of two separate if statements, but it's simpler to use the &amp;quot;else&amp;quot; statement.&lt;br /&gt;
  local Num1 = 1&lt;br /&gt;
  local Num2 = 2&lt;br /&gt;
  &lt;br /&gt;
  --Using multiple if&lt;br /&gt;
  if Num1 &amp;gt; Num2 then&lt;br /&gt;
    write(&amp;quot;Number 1 is greater!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
  if Num1 &amp;lt;= Num2 then&lt;br /&gt;
    write(&amp;quot;Number 1 is not greater!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
  --Using else&lt;br /&gt;
  if Num1&amp;gt;Num2 then&lt;br /&gt;
    write(&amp;quot;Number 1 is greater!\n&amp;quot;)&lt;br /&gt;
  else&lt;br /&gt;
    write(&amp;quot;Number 1 is not greater!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== The ElseIf statement ==&lt;br /&gt;
&lt;br /&gt;
Sometimes it may be desirable to run the &amp;quot;else&amp;quot; code only under certain conditions. This is where &amp;quot;elseif&amp;quot; becomes useful. It acts as if it is another if statement, but also functions as the &amp;quot;else&amp;quot; of the if it's in.&lt;br /&gt;
&lt;br /&gt;
 local Num1, Num2, Num3 = 1,2,3&lt;br /&gt;
 &lt;br /&gt;
 --Without elseif&lt;br /&gt;
 if Num1&amp;gt;Num2 then&lt;br /&gt;
   write(&amp;quot;First condition passed!\n&amp;quot;)&lt;br /&gt;
 elseif Num3&amp;gt;Num2 then&lt;br /&gt;
   write(&amp;quot;First condition failed, second condition passed!\n&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;elseif&amp;quot; statement can become even more useful if you chain together more &amp;quot;elseif&amp;quot;s and &amp;quot;else&amp;quot;s with it, but remember that the first if that passes will break the chain!&lt;br /&gt;
 if Bool then&lt;br /&gt;
   --Stuff&lt;br /&gt;
 elseif Var1 == Var2 then&lt;br /&gt;
   --Other stuff&lt;br /&gt;
 elseif Table[1] then&lt;br /&gt;
   --More stuff&lt;br /&gt;
 else&lt;br /&gt;
   --More again!&lt;br /&gt;
 end&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Conditional_statements&amp;diff=1572</id>
		<title>Conditional statements</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Conditional_statements&amp;diff=1572"/>
				<updated>2012-05-19T18:47:01Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: Created page with &amp;quot;This is a tutorial will teach you how to make your script react to different situations.  == The If statement ==  Conditional statements are one of the fundamental building bl...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a tutorial will teach you how to make your script react to different situations.&lt;br /&gt;
&lt;br /&gt;
== The If statement ==&lt;br /&gt;
&lt;br /&gt;
Conditional statements are one of the fundamental building blocks for any coding languages. They are just as they sound, if a condition is met then a block of code will run. The simplest form of conditional statement available in Lua is the &amp;quot;If&amp;quot; statement, which indicates that if one or more conditions are met, the following block of code will run. If statements take the following format&lt;br /&gt;
  local Variable = 1&lt;br /&gt;
  if Variable==1 then&lt;br /&gt;
    write(&amp;quot;The variable is 1!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
  if Variable==2 then&lt;br /&gt;
    write(&amp;quot;The variable is 2!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
This script will simply output the text &amp;quot;The variable is 1!&amp;quot;. The &amp;quot;==&amp;quot; operator simply means &amp;quot;is equal to&amp;quot;, so the line reads along the lines of &amp;quot;If Variable is equal to 1, then do this&amp;quot;. &amp;quot;end&amp;quot; marks the end of the code block, and anything after it is run normally regardless of whether the conditions were met.&lt;br /&gt;
&lt;br /&gt;
Brackets may optionally be used around conditions, although it is not necessary unless you want to control the order of a calculation.&lt;br /&gt;
&lt;br /&gt;
Note that since lua disregards new lines, it would be equally acceptable to write the following&lt;br /&gt;
 if Variable==1 then write(&amp;quot;The variable is 1!\n&amp;quot;) end&lt;br /&gt;
However, this method is generally less readable and not commonly used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lua determines whether an if statement passes by using the boolean values returned by the condition, so it would be possible but unnecessary to enter a boolean as the condition as follows&lt;br /&gt;
 if true then write(&amp;quot;This will always write!\n&amp;quot;)&lt;br /&gt;
 if false then write(&amp;quot;This will never write!\n&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
== Available conditions ==&lt;br /&gt;
There are a number of different conditions that can be used to make the &lt;br /&gt;
&lt;br /&gt;
;Is equal to&lt;br /&gt;
  if Variable == Variable2 then&lt;br /&gt;
    --Do stuff&lt;br /&gt;
  end&lt;br /&gt;
The &amp;quot;==&amp;quot; condition is the most basic operator, simply comparing two values to see if they are the same. If both values are the same, the condition is met and the if statement passes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Is not equal to&lt;br /&gt;
  if Variable ~= Variable2 then&lt;br /&gt;
    --Do stuff&lt;br /&gt;
  end&lt;br /&gt;
The &amp;quot;~=&amp;quot; condition compares two values to see if they are the same, and if they are ''not'' the same, the condition is met and the if statement passes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Greater than&lt;br /&gt;
  if Number &amp;gt; Number2 then&lt;br /&gt;
    --Do stuff&lt;br /&gt;
  end&lt;br /&gt;
The &amp;quot;&amp;gt;&amp;quot; condition compares two number values, and if the first is greater than the second, the condition is met and the if statement passes. The &amp;quot;&amp;gt;=&amp;quot; (Greater than or equal to) operator acts as both the &amp;quot;greater than&amp;quot; and the &amp;quot;equal to&amp;quot; conditions, meaning the condition is met if either the first number is equal to the second, or the first number is greater than the second.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;Less than&lt;br /&gt;
  if Number &amp;lt; Number2 then&lt;br /&gt;
    --Do stuff&lt;br /&gt;
  end&lt;br /&gt;
The &amp;quot;&amp;lt;&amp;quot; condition compares two number values, and if the first is lower than the second, the condition is met and the if statement passes. The &amp;quot;&amp;lt;=&amp;quot; (Less than or equal to) operator acts as a combination of the &amp;quot;less than&amp;quot; and the &amp;quot;equal to&amp;quot; conditions.&lt;br /&gt;
&lt;br /&gt;
=== And, Or, Not ===&lt;br /&gt;
&lt;br /&gt;
Sometimes it is desirable to combine conditions. Although it is possible to use multiple if statements, or ifs inside ifs, it is a best practice to use &amp;quot;and&amp;quot; and &amp;quot;or&amp;quot; if possible.&lt;br /&gt;
&lt;br /&gt;
;And&lt;br /&gt;
 local Num1,Num2,Num3 = 1,2,3&lt;br /&gt;
 &lt;br /&gt;
 --Multiple if&lt;br /&gt;
 if Num1 &amp;gt; Num2 then&lt;br /&gt;
   if Num2 &amp;lt; Num3 then&lt;br /&gt;
     write(&amp;quot;Condition is true!&amp;quot;)&lt;br /&gt;
   end&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 --Using And&lt;br /&gt;
 if (Num1&amp;gt;Num2) and (Num2&amp;lt;Num3) then&lt;br /&gt;
   write(&amp;quot;Condition is true!&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;and&amp;quot; operator means that both conditions must match before the statement passes. If either side fails, the whole condition is false. Note that if the left side fails, the right side is ignored, so if you have a critical function it should be on the left of the &amp;quot;and&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
;Or&lt;br /&gt;
 local Num1,Num2,Num3 = 1,2,3&lt;br /&gt;
 &lt;br /&gt;
 --Multiple if&lt;br /&gt;
 if Num1 &amp;gt; Num2 then&lt;br /&gt;
   write(&amp;quot;Condition is true!&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
 if Num2 &amp;lt; Num3 then&lt;br /&gt;
   write(&amp;quot;Condition is true!&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
 &lt;br /&gt;
 --Using Or&lt;br /&gt;
 if (Num1&amp;gt;Num2) or (Num2&amp;lt;Num3) then&lt;br /&gt;
   write(&amp;quot;Condition is true!&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;or&amp;quot; operator means that if either condition matches the statement passes. This means that if either the left side, the right side, or both pass, the statement is true. Note that if the left side passes, the right side is ignored, so if you have a critical function it should be on the left of the &amp;quot;or&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
;Not&lt;br /&gt;
 local Num1,Num2,Num3 = 1,2,3&lt;br /&gt;
 &lt;br /&gt;
 if (Num1 &amp;lt; Num2) and not (Num1 &amp;gt; Num3) then&lt;br /&gt;
   write(&amp;quot;Condition is true!&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
While the &amp;quot;not&amp;quot; statement is rarely a necessity, it can be used to reverse a value from &amp;quot;true&amp;quot; to &amp;quot;false&amp;quot; or vice versa.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In some situations, it may be preferable not to use these statements as code will run before the second condition needs to be assessed, such as as follows&lt;br /&gt;
 local Num1,Num2 = 1,2&lt;br /&gt;
 &lt;br /&gt;
 --And should not be used here&lt;br /&gt;
 if Num1&amp;gt;Num2 then&lt;br /&gt;
   local Num3 = 3&lt;br /&gt;
   &lt;br /&gt;
   if Num3&amp;gt;Num2 then write(&amp;quot;Text!\n&amp;quot;) end&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
== The Else statement ==&lt;br /&gt;
&lt;br /&gt;
It is common that you may want to run some code on the failure of the condition. If this is the case, it may be achieved through the use of two separate if statements, but it's simpler to use the &amp;quot;else&amp;quot; statement.&lt;br /&gt;
  local Num1 = 1&lt;br /&gt;
  local Num2 = 2&lt;br /&gt;
  &lt;br /&gt;
  --Using multiple if&lt;br /&gt;
  if Num1 &amp;gt; Num2 then&lt;br /&gt;
    write(&amp;quot;Number 1 is greater!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
  if Num1 &amp;lt;= Num2 then&lt;br /&gt;
    write(&amp;quot;Number 1 is not greater!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
  --Using else&lt;br /&gt;
  if Num1&amp;gt;Num2 then&lt;br /&gt;
    write(&amp;quot;Number 1 is greater!\n&amp;quot;)&lt;br /&gt;
  else&lt;br /&gt;
    write(&amp;quot;Number 1 is not greater!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
== The ElseIf statement ==&lt;br /&gt;
&lt;br /&gt;
Sometimes it may be desirable to run the &amp;quot;else&amp;quot; code only under certain conditions. This is where &amp;quot;elseif&amp;quot; becomes useful. It acts as if it is another if statement, but also functions as the &amp;quot;else&amp;quot; of the if it's in.&lt;br /&gt;
&lt;br /&gt;
 local Num1, Num2, Num3 = 1,2,3&lt;br /&gt;
 &lt;br /&gt;
 --Without elseif&lt;br /&gt;
 if Num1&amp;gt;Num2 then&lt;br /&gt;
   write(&amp;quot;First condition passed!\n&amp;quot;)&lt;br /&gt;
 elseif Num3&amp;gt;Num2 then&lt;br /&gt;
   write(&amp;quot;First condition failed, second condition passed!\n&amp;quot;)&lt;br /&gt;
 end&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;elseif&amp;quot; statement can become even more useful if you chain together more &amp;quot;elseif&amp;quot;s and &amp;quot;else&amp;quot;s with it, but remember that the first if that passes will break the chain!&lt;br /&gt;
 if Bool then&lt;br /&gt;
   --Stuff&lt;br /&gt;
 elseif Var1 == Var2 then&lt;br /&gt;
   --Other stuff&lt;br /&gt;
 elseif Table[1] then&lt;br /&gt;
   --More stuff&lt;br /&gt;
 else&lt;br /&gt;
   --More again!&lt;br /&gt;
 end&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Variables&amp;diff=1571</id>
		<title>Variables</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Variables&amp;diff=1571"/>
				<updated>2012-05-19T18:13:53Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: /* What do variables look like? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Tutorials]]&lt;br /&gt;
This is a tutorial page for Variables and their function.&lt;br /&gt;
&lt;br /&gt;
== What are Variables? ==&lt;br /&gt;
&lt;br /&gt;
Variables are one of the fundamental building blocks of all coding languages. Variables are just as they sound, they can store a changeable value.&lt;br /&gt;
&lt;br /&gt;
== What do variables look like? ==&lt;br /&gt;
&lt;br /&gt;
Variables will usually be defined near the start of a script or function (Functions will be taught in a later tutorial), as this will make them easy to edit later if required. Variables can be defined in a number of different ways, reliant on the type of data that is being stored.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; String values&lt;br /&gt;
String variables can store any text or &amp;quot;string&amp;quot; that you will use in your script. Strings can be defined as follows&lt;br /&gt;
 local Text = 'This is a string!'&lt;br /&gt;
 local MoreText = &amp;quot;This is also a string!&amp;quot;&lt;br /&gt;
String values have the unique ability to be concatenated (One added to the end of the other). To do this, simply enter a &amp;quot;..&amp;quot; between the two strings or variables.&lt;br /&gt;
 local Start = &amp;quot;This is&amp;quot;&lt;br /&gt;
 local Middle = &amp;quot; all part of &amp;quot;&lt;br /&gt;
 local End = &amp;quot;one sentence!\n&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 Start = Start..Middle&lt;br /&gt;
 &lt;br /&gt;
 write(Start..End)&lt;br /&gt;
This will write &amp;quot;This is all part of one sentence!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Number values&lt;br /&gt;
Number variables can store any number used in the script, as well as perform calculations with them.&lt;br /&gt;
Numbers can be defined as follows&lt;br /&gt;
 local Number = 1&lt;br /&gt;
 local AnotherNumber = 2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Boolean values&lt;br /&gt;
Boolean variables are simply a &amp;quot;True or False?&amp;quot; variable. They can be either true or false, but nothing else. Boolean values are usually used for conditional statements, which will be covered in a later tutorial.&lt;br /&gt;
Boolean variables can be defined as follows&lt;br /&gt;
 local Bool = true&lt;br /&gt;
 local Bool2 = false&lt;br /&gt;
Note that &amp;quot;true&amp;quot; and &amp;quot;false&amp;quot; are case sensitive.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Nil values&lt;br /&gt;
Nil values are values that are currently storing nothing. Usually you will not explicitly set a variable to nil, as it acts similar to a &amp;quot;false&amp;quot; boolean. All variables are nil by default.&lt;br /&gt;
 local Variable = nil&lt;br /&gt;
Note that &amp;quot;nil&amp;quot; is case sensitive&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Table values&lt;br /&gt;
Table variables are variables that can store any other variables, including more tables. They will be described in more depth in a later tutorial.&lt;br /&gt;
Tables can be defined as follows&lt;br /&gt;
 local EmptyTable = {}&lt;br /&gt;
 local Table = {1,2,3,4}&lt;br /&gt;
 local AnotherTable = {&amp;quot;This table&amp;quot;, &amp;quot;Contains&amp;quot;, 3, {&amp;quot;Types of variables!&amp;quot;} }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Function values&lt;br /&gt;
Although not often considered variables, Lua functions can act the same way as other more standard variables. Functions will be described in more detail in a later tutorial.&lt;br /&gt;
functions can be defined as follows&lt;br /&gt;
  local DoStuff = function() end&lt;br /&gt;
  local function AnotherFunction() end&lt;br /&gt;
  &lt;br /&gt;
  local DoStuff2 = function()&lt;br /&gt;
    write(&amp;quot;Function!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
  local function AnotherFunction2()&lt;br /&gt;
    write(&amp;quot;Another function!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
Function and table variables are usually defined over multiple lines due to the length of them. In Lua, a new line does not mark any functionality and is used purely for readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unlike many other languages, Lua allows for variable's data types to be changed as you go, easily overwriting, for example, a string with a number.&lt;br /&gt;
  local Variable = &amp;quot;String!&amp;quot; --The variable is a string&lt;br /&gt;
  Variable = 1 --The variable is now a number&lt;br /&gt;
&lt;br /&gt;
== What is &amp;quot;local&amp;quot; and why is it useful? ==&lt;br /&gt;
You may have noticed the use of &amp;quot;local&amp;quot; in the above declarations. &amp;quot;local&amp;quot; simply states that the variable being defined should only be used in this script or function. You only need to write local for the first time you set a variable, then it will assume every other time you use the variable afterwords it is the local variable. If you use or set a variable without using local, it will try and use or set a global variable which can be used and modified by other scripts.&lt;br /&gt;
&lt;br /&gt;
Although it likely won't be an issue when you are using ComputerCraft, it is advisable to use local variables and functions when possible, so they will not be unintentionally edited by other functions or scripts.&lt;br /&gt;
&lt;br /&gt;
== Multiple assignments ==&lt;br /&gt;
Variables don't necessarily need to be defined one at a time, it is possible to assign multiple values in one operation through the use of commas.&lt;br /&gt;
  local Var1, Var2 = &amp;quot;One&amp;quot;, &amp;quot;Two&amp;quot;&lt;br /&gt;
  write( Var1..Var2..&amp;quot;\n&amp;quot; )&lt;br /&gt;
This script will successfully assign the values &amp;quot;One&amp;quot; and &amp;quot;Two&amp;quot;, then write &amp;quot;OneTwo&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==What have we learned?==&lt;br /&gt;
*Variables can store values&lt;br /&gt;
*Variables store different types of values&lt;br /&gt;
*Variables can be defined in different ways&lt;br /&gt;
*An overview of what different variable types do&lt;br /&gt;
*Use &amp;quot;local&amp;quot; to use variables locally&lt;br /&gt;
*Muitlple values may be assigned at once&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Variables&amp;diff=1570</id>
		<title>Variables</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Variables&amp;diff=1570"/>
				<updated>2012-05-19T18:12:27Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: /* What do variables look like? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Tutorials]]&lt;br /&gt;
This is a tutorial page for Variables and their function.&lt;br /&gt;
&lt;br /&gt;
== What are Variables? ==&lt;br /&gt;
&lt;br /&gt;
Variables are one of the fundamental building blocks of all coding languages. Variables are just as they sound, they can store a changeable value.&lt;br /&gt;
&lt;br /&gt;
== What do variables look like? ==&lt;br /&gt;
&lt;br /&gt;
Variables will usually be defined near the start of a script or function (Functions will be taught in a later tutorial), as this will make them easy to edit later if required. Variables can be defined in a number of different ways, reliant on the type of data that is being stored.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; String values&lt;br /&gt;
String variables can store any text or &amp;quot;string&amp;quot; that you will use in your script&lt;br /&gt;
Strings can be defined as follows&lt;br /&gt;
 local Text = 'This is a string!'&lt;br /&gt;
 local MoreText = &amp;quot;This is also a string!&amp;quot;&lt;br /&gt;
String values have the unique ability to be concatenated (One added to the end of the other). To do this, simply enter a &amp;quot;..&amp;quot; between the two strings or variables.&lt;br /&gt;
 local Start = &amp;quot;This is&amp;quot;&lt;br /&gt;
 local Middle = &amp;quot; all part of &amp;quot;&lt;br /&gt;
 local End = &amp;quot;one sentence!\n&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 Start = Start..Middle&lt;br /&gt;
 &lt;br /&gt;
 write(Start..End)&lt;br /&gt;
This will write &amp;quot;This is all part of one sentence!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Number values&lt;br /&gt;
Number variables can store any number used in the script, as well as perform calculations with them.&lt;br /&gt;
Numbers can be defined as follows&lt;br /&gt;
 local Number = 1&lt;br /&gt;
 local AnotherNumber = 2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Boolean values&lt;br /&gt;
Boolean variables are simply a &amp;quot;True or False?&amp;quot; variable. They can be either true or false, but nothing else. Boolean values are usually used for conditional statements, which will be covered in a later tutorial.&lt;br /&gt;
Boolean variables can be defined as follows&lt;br /&gt;
 local Bool = true&lt;br /&gt;
 local Bool2 = false&lt;br /&gt;
Note that &amp;quot;true&amp;quot; and &amp;quot;false&amp;quot; are case sensitive.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Nil values&lt;br /&gt;
Nil values are values that are currently storing nothing. Usually you will not explicitly set a variable to nil, as it acts similar to a &amp;quot;false&amp;quot; boolean. All variables are nil by default.&lt;br /&gt;
 local Variable = nil&lt;br /&gt;
Note that &amp;quot;nil&amp;quot; is case sensitive&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Table values&lt;br /&gt;
Table variables are variables that can store any other variables, including more tables. They will be described in more depth in a later tutorial.&lt;br /&gt;
Tables can be defined as follows&lt;br /&gt;
 local EmptyTable = {}&lt;br /&gt;
 local Table = {1,2,3,4}&lt;br /&gt;
 local AnotherTable = {&amp;quot;This table&amp;quot;, &amp;quot;Contains&amp;quot;, 3, {&amp;quot;Types of variables!&amp;quot;} }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Function values&lt;br /&gt;
Although not often considered variables, Lua functions can act the same way as other more standard variables. functions will be described in more detail in a later tutorial.&lt;br /&gt;
functions can be defined as follows&lt;br /&gt;
  local DoStuff = function() end&lt;br /&gt;
  local function AnotherFunction() end&lt;br /&gt;
  &lt;br /&gt;
  local DoStuff2 = function()&lt;br /&gt;
    write(&amp;quot;Function!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
  local function AnotherFunction2()&lt;br /&gt;
    write(&amp;quot;Another function!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
Function and table variables are usually defined over multiple lines due to the length of them. In Lua, a new line does not mark any functionality and is used purely for readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unlike many other languages, Lua allows for variable's data types to be changed as you go, easily overwriting, for example, a string with a number.&lt;br /&gt;
  local Variable = &amp;quot;String!&amp;quot; --The variable is a string&lt;br /&gt;
  Variable = 1 --The variable is now a number&lt;br /&gt;
&lt;br /&gt;
== What is &amp;quot;local&amp;quot; and why is it useful? ==&lt;br /&gt;
You may have noticed the use of &amp;quot;local&amp;quot; in the above declarations. &amp;quot;local&amp;quot; simply states that the variable being defined should only be used in this script or function. You only need to write local for the first time you set a variable, then it will assume every other time you use the variable afterwords it is the local variable. If you use or set a variable without using local, it will try and use or set a global variable which can be used and modified by other scripts.&lt;br /&gt;
&lt;br /&gt;
Although it likely won't be an issue when you are using ComputerCraft, it is advisable to use local variables and functions when possible, so they will not be unintentionally edited by other functions or scripts.&lt;br /&gt;
&lt;br /&gt;
== Multiple assignments ==&lt;br /&gt;
Variables don't necessarily need to be defined one at a time, it is possible to assign multiple values in one operation through the use of commas.&lt;br /&gt;
  local Var1, Var2 = &amp;quot;One&amp;quot;, &amp;quot;Two&amp;quot;&lt;br /&gt;
  write( Var1..Var2..&amp;quot;\n&amp;quot; )&lt;br /&gt;
This script will successfully assign the values &amp;quot;One&amp;quot; and &amp;quot;Two&amp;quot;, then write &amp;quot;OneTwo&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==What have we learned?==&lt;br /&gt;
*Variables can store values&lt;br /&gt;
*Variables store different types of values&lt;br /&gt;
*Variables can be defined in different ways&lt;br /&gt;
*An overview of what different variable types do&lt;br /&gt;
*Use &amp;quot;local&amp;quot; to use variables locally&lt;br /&gt;
*Muitlple values may be assigned at once&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	<entry>
		<id>https://www.computercraft.info/wiki/index.php?title=Variables&amp;diff=1569</id>
		<title>Variables</title>
		<link rel="alternate" type="text/html" href="https://www.computercraft.info/wiki/index.php?title=Variables&amp;diff=1569"/>
				<updated>2012-05-19T18:08:05Z</updated>
		
		<summary type="html">&lt;p&gt;My hat stinks: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Tutorials]]&lt;br /&gt;
This is a tutorial page for Variables and their function.&lt;br /&gt;
&lt;br /&gt;
== What are Variables? ==&lt;br /&gt;
&lt;br /&gt;
Variables are one of the fundamental building blocks of all coding languages. Variables are just as they sound, they can store a changeable value.&lt;br /&gt;
&lt;br /&gt;
== What do variables look like? ==&lt;br /&gt;
&lt;br /&gt;
Variables will usually be defined near the start of a script or function (Functions will be taught in a later tutorial), as this will make them easy to edit later if required. Variables can be defined in a number of different ways, reliant on the type of data that is being stored.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; String values&lt;br /&gt;
String variables can store any text or &amp;quot;string&amp;quot; that you will use in your script&lt;br /&gt;
Strings can be defined as follows&lt;br /&gt;
 local Text = 'This is a string!'&lt;br /&gt;
 local MoreText = &amp;quot;This is also a string!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Number values&lt;br /&gt;
Number variables can store any number used in the script, as well as perform calculations with them.&lt;br /&gt;
Numbers can be defined as follows&lt;br /&gt;
 local Number = 1&lt;br /&gt;
 local AnotherNumber = 2&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Boolean values&lt;br /&gt;
Boolean variables are simply a &amp;quot;True or False?&amp;quot; variable. They can be either true or false, but nothing else. Boolean values are usually used for conditional statements, which will be covered in a later tutorial.&lt;br /&gt;
Boolean variables can be defined as follows&lt;br /&gt;
 local Bool = true&lt;br /&gt;
 local Bool2 = false&lt;br /&gt;
Note that &amp;quot;true&amp;quot; and &amp;quot;false&amp;quot; are case sensitive.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Nil values&lt;br /&gt;
Nil values are values that are currently storing nothing. Usually you will not explicitly set a variable to nil, as it acts similar to a &amp;quot;false&amp;quot; boolean. All variables are nil by default.&lt;br /&gt;
 local Variable = nil&lt;br /&gt;
Note that &amp;quot;nil&amp;quot; is case sensitive&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Table values&lt;br /&gt;
Table variables are variables that can store any other variables, including more tables. They will be described in more depth in a later tutorial.&lt;br /&gt;
Tables can be defined as follows&lt;br /&gt;
 local EmptyTable = {}&lt;br /&gt;
 local Table = {1,2,3,4}&lt;br /&gt;
 local AnotherTable = {&amp;quot;This table&amp;quot;, &amp;quot;Contains&amp;quot;, 3, {&amp;quot;Types of variables!&amp;quot;} }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; Function values&lt;br /&gt;
Although not often considered variables, Lua functions can act the same way as other more standard variables. functions will be described in more detail in a later tutorial.&lt;br /&gt;
functions can be defined as follows&lt;br /&gt;
  local DoStuff = function() end&lt;br /&gt;
  local function AnotherFunction() end&lt;br /&gt;
  &lt;br /&gt;
  local DoStuff2 = function()&lt;br /&gt;
    write(&amp;quot;Function!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
  local function AnotherFunction2()&lt;br /&gt;
    write(&amp;quot;Another function!\n&amp;quot;)&lt;br /&gt;
  end&lt;br /&gt;
Function and table variables are usually defined over multiple lines due to the length of them. In Lua, a new line does not mark any functionality and is used purely for readability.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Unlike many other languages, Lua allows for variable's data types to be changed as you go, easily overwriting, for example, a string with a number.&lt;br /&gt;
  local Variable = &amp;quot;String!&amp;quot; --The variable is a string&lt;br /&gt;
  Variable = 1 --The variable is now a number&lt;br /&gt;
&lt;br /&gt;
== What is &amp;quot;local&amp;quot; and why is it useful? ==&lt;br /&gt;
You may have noticed the use of &amp;quot;local&amp;quot; in the above declarations. &amp;quot;local&amp;quot; simply states that the variable being defined should only be used in this script or function. You only need to write local for the first time you set a variable, then it will assume every other time you use the variable afterwords it is the local variable. If you use or set a variable without using local, it will try and use or set a global variable which can be used and modified by other scripts.&lt;br /&gt;
&lt;br /&gt;
Although it likely won't be an issue when you are using ComputerCraft, it is advisable to use local variables and functions when possible, so they will not be unintentionally edited by other functions or scripts.&lt;br /&gt;
&lt;br /&gt;
== Multiple assignments ==&lt;br /&gt;
Variables don't necessarily need to be defined one at a time, it is possible to assign multiple values in one operation through the use of commas.&lt;br /&gt;
  local Var1, Var2 = &amp;quot;One&amp;quot;, &amp;quot;Two&amp;quot;&lt;br /&gt;
  write( Var1..Var2..&amp;quot;\n&amp;quot; )&lt;br /&gt;
This script will successfully assign the values &amp;quot;One&amp;quot; and &amp;quot;Two&amp;quot;, then write &amp;quot;OneTwo&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==What have we learned?==&lt;br /&gt;
*Variables can store values&lt;br /&gt;
*Variables store different types of values&lt;br /&gt;
*Variables can be defined in different ways&lt;br /&gt;
*An overview of what different variable types do&lt;br /&gt;
*Use &amp;quot;local&amp;quot; to use variables locally&lt;br /&gt;
*Muitlple values may be assigned at once&lt;/div&gt;</summary>
		<author><name>My hat stinks</name></author>	</entry>

	</feed>