Advertisement
Fulgar

ComputerCraft - Lumberjack Turtle 2.0

Apr 17th, 2015
2,396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.69 KB | None | 0 0
  1. --"Lumberjack Turtle" v2.0
  2. -- Created by: Jeff "Deczx" Kloos, edited by: Daniele "Raniel" Sabre, Fulgar
  3. --                                      -------READ BELOW FOR INSTRUCTIONS--------
  4. -- This is a program that makes a ComputerCraft Mine Turtle chop down trees for you. It is fully automatic and replants after chopping the tree down.
  5. -- Quick start: The way you have to set it up is pretty simple. Put a chest in the ground and place the turtle on top. Put a sapling of your choice in front of the turtle. Put a single sapling of the corresponding wood in the 4th inventory slot of the turtle (top-right). Now put some saplings in the 16th inventory slot (bottom-right) for the turtle to replant. Fuel up the turtle, run the program and voila!
  6.  
  7. local waitTime = 10
  8.  
  9.  
  10. print("Well I'm a lumberjack and I'm OK! ^.^")
  11. print("[hold ctrl+t to terminate]")
  12.  
  13. while turtle.getFuelLevel() > 20 do -- If the Fuel gets below 64 the loop stops, you can change this, of course.
  14.     --Here, the turtle looks for the sapling to turn into the woodblock.
  15.     local success, sapling = turtle.inspect()
  16.     while c do
  17.         for i = 1,16 do -- search bone meal
  18.             item = turtle.getItemDetail(i)
  19.             if item == nil then
  20.                 c = true
  21.             else
  22.                 if item.name == "minecraft:dye" then
  23.                     turtle.select(i)
  24.                     turtle.place()
  25.                 end
  26.                 success, sapling = turtle.inspect()
  27.             end
  28.         end
  29.         sleep(waitTime)
  30.         success, sapling = turtle.inspect()
  31.         if sapling.name == "minecraft:log" then
  32.             c = false
  33.         else
  34.             c = true
  35.         end
  36.     end
  37.  
  38.     --If it sees that the sapling is a woodblock it will start cutting the tree down.
  39.     turtle.select(1)
  40.     turtle.dig()
  41.     turtle.forward()
  42.     print("Aye! ^o^7")
  43.  
  44.     -- The turtle will keep going up until there are no more blocks above him.
  45.     while turtle.detectUp()  do
  46.         turtle.digUp()
  47.         turtle.up()
  48.     end
  49.  
  50.     -- Then it will go down.
  51.     while turtle.down() == true do
  52.     end
  53.  
  54.     -- Until it hits the ground.
  55.     turtle.back()
  56.     for i = 1,16 do -- search oak sapling
  57.         item = turtle.getItemDetail(i)
  58.         if item == nil then
  59.             c = true
  60.         else
  61.             if item.name == "minecraft:sapling" then
  62.                 turtle.select(i)
  63.                 turtle.place()
  64.                 i=16
  65.             end
  66.         end
  67.     end
  68.  
  69.     for i = 1,16 do -- search oak wood
  70.         item = turtle.getItemDetail(i)
  71.         if item == nil then
  72.             c = true
  73.         else
  74.             if item.name == "minecraft:log" then
  75.                 turtle.select(i)
  76.                 if turtle.getFuelLevel() < 100 then
  77.                     turtle.refuel(1)
  78.                 end
  79.                 turtle.dropDown() -- drop wood on hcest below
  80.             end
  81.         end
  82.     end
  83.     turtle.select(1)
  84.    
  85.     print("Hard Work Makes Me Sleepy! XoX <<ZZzzz>>.") -- Then the turtle will go back to sleep mode.
  86. end
  87.  
  88. -- If the turtle runs out of fuel, it will print a message and terminate the program.
  89. print("So Hungry. -o-")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement