Difference between revisions of "Advanced Turtle Lumberjack (tutorial)"
(Fixed the loop so it actually works. Added forward movement after the first block is removed.) |
Freakout2114 (Talk | contribs) (→The Code) |
||
Line 22: | Line 22: | ||
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. | ||
That's it! | That's it! | ||
+ | |||
+ | ----------------------------------------------------------------------------------------- | ||
+ | |||
+ | '''Another Advanced Turtle Lumberjack''' (Made By Freakout2114) | ||
+ | |||
+ | 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] | ||
+ | <code> | ||
+ | shell.run('clear') | ||
+ | C=1 | ||
+ | X=0 | ||
+ | X1=0 | ||
+ | print("Place Dirt in Slot 1 and Saplings in Slot 2 and 1 log in slot 3 Thankyou :) ") | ||
+ | write("How many trees do you want me to plant X direction?:") | ||
+ | X=io.read() | ||
+ | |||
+ | X=X+0 | ||
+ | X1=X | ||
+ | X1=X1+0 | ||
+ | |||
+ | turtle.up() | ||
+ | turtle.turnLeft() | ||
+ | turtle.turnLeft() | ||
+ | |||
+ | turtle.back() | ||
+ | turtle.back() | ||
+ | turtle.back() | ||
+ | |||
+ | while C>0 do | ||
+ | while X>0 do | ||
+ | turtle.digDown() | ||
+ | turtle.select(1) | ||
+ | turtle.placeDown() | ||
+ | turtle.back() | ||
+ | turtle.select(2) | ||
+ | turtle.place() | ||
+ | turtle.back() | ||
+ | turtle.back() | ||
+ | turtle.back() | ||
+ | X=X-1 | ||
+ | end | ||
+ | C=0 | ||
+ | end | ||
+ | print("Planted Trees!") | ||
+ | |||
+ | turtle.turnLeft() | ||
+ | turtle.forward() | ||
+ | turtle.turnRight() | ||
+ | |||
+ | |||
+ | |||
+ | --/chop trees | ||
+ | X=X1 | ||
+ | C=1 | ||
+ | C=C+0 | ||
+ | while C>0 do | ||
+ | while X>0 do | ||
+ | print("X= "..X.."") | ||
+ | X=X+0 | ||
+ | turtle.forward() | ||
+ | turtle.forward() | ||
+ | turtle.forward() | ||
+ | turtle.forward() | ||
+ | turtle.turnRight() | ||
+ | turtle.select(3) | ||
+ | if turtle.compare()==true then | ||
+ | turtle.dig() | ||
+ | turtle.forward() | ||
+ | |||
+ | while turtle.detectUp() do | ||
+ | turtle.up() | ||
+ | turtle.digUp() | ||
+ | turtle.up() | ||
+ | end | ||
+ | |||
+ | while turtle.detectDown()==false do | ||
+ | turtle.down() | ||
+ | end | ||
+ | turtle.back() | ||
+ | turtle.select(2) | ||
+ | turtle.place() | ||
+ | end | ||
+ | |||
+ | turtle.turnLeft() | ||
+ | X=X-1 | ||
+ | print("X after = "..X.."") | ||
+ | end | ||
+ | turtle.forward() | ||
+ | turtle.turnRight() | ||
+ | turtle.forward() | ||
+ | turtle.forward() | ||
+ | turtle.turnRight() | ||
+ | turtle.forward() | ||
+ | X=X1 | ||
+ | W=turtle.getItemCount(3) | ||
+ | print("I've cut down "..T.." Trees") | ||
+ | print("I've collected "..W.." Logs") | ||
+ | end | ||
+ | </code> | ||
+ | |||
+ | |||
+ | |||
('''Helpful tip:''' Save this to your computercraft/lua/rom/programs folder, then it will be on all turtles.) | ('''Helpful tip:''' Save this to your computercraft/lua/rom/programs folder, then it will be on all turtles.) |
Revision as of 07:30, 3 May 2012
Contents
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. 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.
The Code
turtle.dig() turtle.forward() while turtle.detectUp() do turtle.digUp() turtle.up() end while 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!
Another Advanced Turtle Lumberjack (Made By Freakout2114)
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- ComputerCraft-Turtle-Tree Lumberjack
shell.run('clear') C=1 X=0 X1=0 print("Place Dirt in Slot 1 and Saplings in Slot 2 and 1 log in slot 3 Thankyou :) ") write("How many trees do you want me to plant X direction?:") X=io.read() X=X+0 X1=X X1=X1+0 turtle.up() turtle.turnLeft() turtle.turnLeft() turtle.back() turtle.back() turtle.back() while C>0 do while X>0 do turtle.digDown() turtle.select(1) turtle.placeDown() turtle.back() turtle.select(2) turtle.place() turtle.back() turtle.back() turtle.back() X=X-1 end C=0 end print("Planted Trees!") turtle.turnLeft() turtle.forward() turtle.turnRight() --/chop trees X=X1 C=1 C=C+0 while C>0 do while X>0 do print("X= "..X.."") X=X+0 turtle.forward() turtle.forward() turtle.forward() turtle.forward() turtle.turnRight() turtle.select(3) if turtle.compare()==true then turtle.dig() turtle.forward() while turtle.detectUp() do turtle.up() turtle.digUp() turtle.up() end while turtle.detectDown()==false do turtle.down() end turtle.back() turtle.select(2) turtle.place() end turtle.turnLeft() X=X-1 print("X after = "..X.."") end turtle.forward() turtle.turnRight() turtle.forward() turtle.forward() turtle.turnRight() turtle.forward() X=X1 W=turtle.getItemCount(3) print("I've cut down "..T.." Trees") print("I've collected "..W.." Logs") end
(Helpful tip: Save this to your computercraft/lua/rom/programs folder, then it will be on all turtles.)
Category & Author
A tutorial by TheVarmari. Feel free to correct any mistakes!