Advertisement
VADemon

Tree hugger turtle. 2*2, any tree height | v1.3

Feb 2nd, 2013
1,240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.18 KB | None | 0 0
  1. saplingSlot = 1
  2.  
  3. function drop_all_items()
  4.     for i = 2, 15 do
  5.         turtle.select(i)
  6.         turtle.dropDown( turtle.getItemCount(i) )
  7.         sleep(0.5)
  8.     end
  9.     turtle.select( saplingSlot )
  10. end
  11.  
  12. function cutUp()
  13.     turtle.digUp()
  14.     turtle.up()
  15. end
  16.  
  17. function cutDown()
  18.     turtle.digDown()
  19.     turtle.down()
  20. end
  21.  
  22. function run()
  23.     local height = 0
  24.     turtle.select( saplingSlot )
  25.    
  26.     -- chop down the first block
  27.     turtle.dig()
  28.     turtle.forward() -- ]]
  29.  
  30.     while turtle.digUp()==true do
  31.         turtle.dig()
  32.         turtle.up()
  33.         height = height + 1 --count height of the tree
  34.     end
  35.  
  36.     turtle.turnRight(); turtle.dig(); turtle.forward(); turtle.turnLeft()
  37.  
  38.     for i=1, height do
  39.         cutDown()
  40.         turtle.dig()
  41.     end
  42.  
  43.     --print("End of tree or no blocks found. End of while")
  44.  
  45.     turtle.place()
  46.  
  47.     turtle.turnRight()
  48.     turtle.back()
  49.     turtle.place()
  50.  
  51.     turtle.turnLeft()
  52.     turtle.place()
  53.     turtle.back()
  54.  
  55.     turtle.place()
  56.    
  57.     drop_all_items()
  58.     print("Jobs done! Current height: " ..height)
  59. end
  60.  
  61. while true do
  62. print("while")
  63.     if turtle.compare()==true then --sleep if it's the sapling
  64.         sleep(15)
  65.     else
  66.         run()
  67.         break --you may replace this with sleep(120)
  68.         --so the turtle runs full automatically
  69.     end
  70. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement