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

From ComputerCraft Wiki
Jump to: navigation, search
(The Code)
(The Code)
Line 10: Line 10:
 
== The Code ==
 
== The Code ==
  
<code>
+
<code>while turtle.detect() do
while turtle.detect() do
+
 
  turtle.dig()
 
  turtle.dig()
 
   if turtle.detectUp() then
 
   if turtle.detectUp() then
Line 20: Line 19:
 
while not turtle.detectUp() and not turtle.detect() and not turtle.detectDown() do
 
while not turtle.detectUp() and not turtle.detect() and not turtle.detectDown() do
 
turtle.down()
 
turtle.down()
end
+
end</code>
</code>
+
  
 
This makes us check if there are no blocks to be digged, then we go down until we can't.
 
This makes us check if there are no blocks to be digged, then we go down until we can't.

Revision as of 10:53, 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!