Advertisement
Guest User

chop

a guest
Apr 14th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.46 KB | None | 0 0
  1. function move()
  2.     turtle.dig()
  3.     turtle.forward()
  4. end
  5.  
  6. function turn()
  7.     turtle.turnRight()
  8.     move()
  9. end
  10.  
  11. function chopUp()
  12.     while turtle.detectUp() do
  13.         turtle.digUp()
  14.         turtle.up()
  15.     end
  16. end
  17.  
  18. function checkBelow()
  19.     if turtle.detectDown() then
  20.         success, data = turtle.inspectDown()
  21.         if success then
  22.             if data.name ~= "minecraft:log" or data.name ~= "minecraft:leaves" then
  23.                 return false
  24.             end
  25.         end
  26.     else
  27.         return false
  28.     end
  29. end
  30.    
  31.  
  32. function chopDown()
  33.     repeat
  34.         turtle.digDown()
  35.         turtle.down()
  36.     until not checkBelow()
  37. end
  38.  
  39. function placeSapling()
  40.     turtle.select(2)
  41.     turtle.place()
  42.     turtle.select(1)
  43. end
  44.    
  45. function reUp()
  46.     if turtle.getItemCount(1) == 0 then
  47.         turtle.select(1)
  48.         turtle.suckDown()
  49.     end
  50. end
  51.  
  52. function treeGrew()
  53.     local success, data = turtle.inspect()
  54.     if success then
  55.         if data.name == "minecraft:log" or data.name == "minecraft:log"then
  56.             return true;
  57.         else
  58.             return false;
  59.         end
  60.     end
  61. end
  62.  
  63. function growTree()
  64.     repeat
  65.         reUp()
  66.         turtle.place()
  67.     until treeGrew()        
  68. end
  69.        
  70.  
  71. while true do
  72.     growTree()
  73.     move()
  74.     chopUp()
  75.     move()
  76.     chopUp()  
  77.     chopDown()
  78.     turn()
  79.     chopUp()
  80.     move()
  81.     chopUp()
  82.     chopDown()
  83.     turn()
  84.     placeSapling()
  85. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement