Difference between revisions of "Advanced Turtle Lumberjack (tutorial)"

From ComputerCraft Wiki
Jump to: navigation, search
(Created page with " == Advanced Turtle Lumberjack == === Introduction === Welcome to this tutorial about Advanced Turtle Lumberjacks. See the [[Turtle_Lumberjack_(tutoria...")
 
(The Code)
Line 9: Line 9:
  
 
== The Code ==
 
== The Code ==
First, we start with the basics.
 
<code>
 
while turtle.detect() do
 
 
end
 
</code>
 
 
This makes us loop until there is no blocks in front of the turtle.
 
 
<code>
 
while turtle.detect() do
 
  turtle.dig()
 
end
 
</code>
 
 
This makes it dig the block. Now we make it see if there is a block ABOVE it.
 
 
<code>
 
while turtle.detect() do
 
  turtle.dig()
 
  if turtle.detectUp()
 
    turtle.digUp()
 
  end
 
end
 
</code>
 
 
This makes us dig the block above if there is one.
 
Let's make us move up.
 
 
<code>
 
while turtle.detect() do
 
  turtle.dig()
 
  if turtle.detectUp()
 
    turtle.digUp()
 
  turtle.up()
 
  end
 
end
 
</code>
 
 
Now, let's make it come back down when there is no blocks to be digged.
 
  
 
<code>
 
<code>
while turtle.detect() do
+
while turtle.detect() do
  turtle.dig()
+
turtle.dig()
  if turtle.detectUp()
+
  if turtle.detectUp() then
    turtle.digUp()
+
  turtle.digUp()
   turtle.up()
+
   end
  end
+
turtle.up()
end
+
  end
while not turtle.detect() and not turtle.detectUp() and turtle.detectDown() do
+
while not turtle.detectUp() and not turtle.detect() and not turtle.detectDown() do
  turtle.down()
+
turtle.down()
end
+
end
 
</code>
 
</code>
  

Revision as of 10:52, 27 February 2012

Advanced Turtle Lumberjack

Introduction

Welcome to this tutorial about Advanced Turtle Lumberjacks. See the Turtle Lumberjack Tutorial first.

What are Advanced Turtle Lumberjacks?

Advanced Turtle Lumberjacks are basically Turtle Lumberjacks that can dig blocks above them.

The Code

while turtle.detect() do

turtle.dig()
 if turtle.detectUp() then
  turtle.digUp()
 end
turtle.up()
 end

while not turtle.detectUp() and not turtle.detect() and not turtle.detectDown() do turtle.down() end

This makes us check if there are no blocks to be digged, then we go down until we can't. That's it!

(Helpful tip: Save this to your computercraft/lua/programs folder, then it will be on all turtles.)

Category & Author

A tutorial by TheVarmari. Feel free to correct any mistakes!