Advertisement
NanoBob

turtle treefarm

Jul 26th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.05 KB | None | 0 0
  1. function chopTree()
  2.     turtle.dig()
  3.     turtle.forward()
  4.     local inspection = turtle.inspectUp()
  5.     if inspection == false or inspection == nil then return end
  6.     local counter = 0
  7.     while inspection.name == "minecraft:log" do
  8.         turtle.digUp()
  9.         turtle.up()
  10.         counter = counter + 1
  11.     end
  12.     for i=1,counter do
  13.         turtle.down()
  14.     end
  15.     turtle.back()
  16.     turtle.select(1)
  17.     turtle.place()
  18.     turtle.back()
  19.     dropOff()
  20. end
  21.  
  22. function dropOff()
  23.     turtle.turnRight()
  24.     turtle.turnRight()
  25.     for i=3,16 do
  26.         local detail = turtle.getItemDetail()
  27.         if detail ~= nil and detail.name == "minecraft:sapling" then
  28.             turtle.select(i)
  29.             turtle.refuel(64)
  30.         elseif detail ~= nil then
  31.             turtle.select(i)
  32.             turtle.drop()
  33.         end
  34.     end
  35.     turtle.turnRight()
  36.     turtle.turnRight()
  37. end
  38.  
  39. function checkTree()
  40.     turtle.forward()
  41.     local inspection = turtle.inspectUp()
  42.     if inspection == false or inspection == nil then
  43.         turtle.back()
  44.         return
  45.     end
  46.     if inspection.name == "minecraft:log" then
  47.         chopTree()
  48.     end
  49.     turtle.back()
  50. end
  51.  
  52. while true do
  53.     checkTree()
  54.     sleep(5)
  55. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement