Guest User

tree

a guest
Dec 14th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.60 KB | None | 0 0
  1. path = 16
  2. direction = 0
  3.  
  4. function plant()
  5.   turtle.select(1)
  6.   if (turtle.getItemCount() <= 10) then
  7.     for z = 3,16 do
  8.       turtle.select(z)
  9.       turtle.transferTo(1)
  10.     end
  11.   elseif (turtle.detect() == false) then
  12.     turtle.place()
  13.   end
  14. end
  15.  
  16. function detect()
  17.   turtle.select(2)
  18.   if (turtle.compare()) then
  19.     felling()
  20.   else
  21.     plant()
  22.   end
  23. end
  24.  
  25. function felling()
  26.   turtle.dig()
  27.   turtle.forward()
  28.   while (turtle.detectUp()) do
  29.     turtle.digUp()
  30.     turtle.up()
  31.     for i = 1,4 do
  32.       turtle.dig()
  33.       turtle.turnRight()
  34.     end
  35.   end
  36.   goDown()
  37.   turtle.back()  
  38. end
  39.  
  40. function goDown()
  41.   while (turtle.down()) do
  42.   end
  43.  
  44.   if (turtle.inspectDown()) then
  45.     local block, type = turtle.inspectDown()
  46.     if (type.name ~= "minecraft:dirt") then
  47.       turtle.digDown()
  48.       goDown()
  49.     end
  50.   end
  51. end
  52.  
  53. function pathing()
  54.   for x = 2,path do
  55.     detect()
  56.    
  57.     if (direction == 1) then
  58.       turtle.turnRight()
  59.       turtle.suck()
  60.       turtle.forward()
  61.       turtle.turnLeft()
  62.     else
  63.       turtle.turnLeft()
  64.       turtle.suck()
  65.       turtle.forward()
  66.       turtle.turnRight()
  67.     end
  68.    
  69.     detect()
  70.   end
  71.  
  72.   if (direction == 1) then
  73.     direction = 0
  74.     bank()
  75.   else
  76.     direction = 1
  77.   end
  78. end
  79.  
  80. function bank()
  81.   for z = 3,15 do
  82.     turtle.select(z)
  83.     turtle.transferTo(1)
  84.     if (turtle.dropDown() == false and turtle.getItemCount() > 0) then
  85.       while (true) do
  86.         turtle.turnRight()
  87.       end
  88.     end
  89.   end
  90. end
  91.  
  92. function main()
  93.    while (true) do
  94.      pathing()
  95.      sleep(60)
  96.    end
  97. end
  98.  
  99. main()
Advertisement
Add Comment
Please, Sign In to add comment