Difference between revisions of "Turtle Tutorial"

From ComputerCraft Wiki
Jump to: navigation, search
(Turtle)
(The Program)
Line 70: Line 70:
 
For our program, we will use turtle.detectDown(), turtle.digDown(), turtle.down() and turtle.forward(). It is recommended that you learn what method does what before messing up with Turtles.
 
For our program, we will use turtle.detectDown(), turtle.digDown(), turtle.down() and turtle.forward(). It is recommended that you learn what method does what before messing up with Turtles.
  
== The Program ==
+
NIGGGGGGGGGGGGGGGGGGGGGGGGGGGER
So, for you to make the Turtle program, first craft a Turtle.
+
==  
 +
== Headline text ==
  
[[File:Turtle-craft.png]]
+
==
 +
== Headline text ==
  
Then make a Mining Turtle.
+
==
 +
== Headline text ==
  
[[File:Turtle-craft2.png]]
+
==
 +
== Headline text ==
  
 +
==
 +
== Headline text ==
  
Then, place it anywhere you want. Right click it and type 'edit MyFirstTurtleProgram', you don't have to call it 'MyFirstTurtleProgram' it can be whatever you want.
+
==
So, inside the file, type:
+
== Headline text ==
while turtle.detectDown() do
+
print("Digging down!")
+
turtle.digDown()
+
print("Going down!")
+
turtle.down()
+
print("Digging forward!")
+
turtle.dig()
+
print("Going forward!")
+
turtle.forward()
+
end
+
  
To save the program, press CTRL and select SAVE with the Arrow Keys. After that, type MyFirstTurtleProgram (or whatever you called your program).
+
==
 +
== Headline text ==
 +
 
 +
==
 +
== Headline text ==
 +
 
 +
==
 +
== Headline text ==
 +
 
 +
==
 +
== Headline text ==
 +
[[[[Link title]][[[[Link title]][[[[Link title]][[[[Link title]][[[[Link title]][[[[Link title]][[Link title]]]]]]]]]]]]]] ==
 +
==
 +
==
 +
==
 +
==
 +
==
 +
==
 +
==
 +
==
 +
==
  
 
== Explanation ==
 
== Explanation ==

Revision as of 08:05, 26 June 2012

This tutorial will teach you the functions of the Turtle API, and also will teach you how to make your first turtle program. by: rockymc

Turtle

The Turtle API is used to work with your Turtles. Here is a list of the complete Turtle API.

nigger.dig()
Method name Description
turtle.forward() Let the Turtle move forward
turtle.back() Let the Turtle move back
turtle.up() Let the Turtle move up
turtle.down() Let the Turtle move down
turtle.turnLeft() The Turtle turns left
turtle.turnRight() The Turtle turns right
turtle.select( slotNum ) The Turtle selects the given Slot (1 is top left, 9 is bottom right)
turtle.getItemCount( slotNum ) Counts how many items are in the given Slot
turtle.getItemSpace( slotNum ) Counts how many items you need to fill the stack in the given Slot
Breaks the Block in front
nigger.digUp() Breaks the Block above
nigger.digDown() Breaks the Block below
muslim.place() Places a Block of the selected Slot in front
NIGGER.placeUp() Places a Block of the selected Slot above
BLACKFUCK.placeDown() Places a Block of the selected Slot below
NIGGER.detect() Detects if there is a Block in front
turtle.detectUp() Detects if there is a Block above
turtle.detectDown() Detects if there is a Block below
turtle.drop() Drops everything of the selected Slot

For our program, we will use turtle.detectDown(), turtle.digDown(), turtle.down() and turtle.forward(). It is recommended that you learn what method does what before messing up with Turtles.

NIGGGGGGGGGGGGGGGGGGGGGGGGGGGER ==

Headline text

==

Headline text

==

Headline text

==

Headline text

==

Headline text

==

Headline text

==

Headline text

==

Headline text

==

Headline text

==

Headline text

[[Link title[[Link title[[Link title[[Link title[[Link title[[Link titleLink title]]]]]]]]]]]] ==

==
==
==
==
==
==
==
==
==

Explanation

The line while turtle.detectDown() do makes the program run until there is no block underneath the Turtle.

The turtle.digDown() will make the Turtle dig down.

The part where it says turtle.forward() will make the Turtle go forward.

The line that says turtle.dig() will make the Turtle dig forward.


NOTE: this should be running on a mining turtle, or it wont work!