Advertisement
VADemon

Tree hugger turtle. 1*1, any tree height | v1.1

Mar 28th, 2013
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.94 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 run()
  18.     local height = 0
  19.     turtle.select( saplingSlot )
  20.    
  21.     -- chop down the first block
  22.     turtle.dig()
  23.     turtle.forward() -- ]]
  24.  
  25.     while turtle.digUp()==true do
  26.         turtle.dig()
  27.         turtle.up()
  28.         height = height + 1 --count height of the tree
  29.     end
  30.  
  31.     turtle.dig()
  32.  
  33.     for i=1, height do
  34.         turtle.down()
  35.     end
  36.  
  37.     --print("End of tree or no blocks found. End of while")
  38.     turtle.back()
  39.    
  40.     turtle.place()
  41.    
  42.     drop_all_items()
  43.     print("Jobs done! Current height: " ..height)
  44. end
  45.  
  46. while true do
  47. print("while")
  48.     if turtle.compare()==true then --sleep if it's the sapling
  49.         sleep(15)
  50.     else
  51.         run()
  52.         break --you may replace this with sleep(120)
  53.         --so the turtle runs full automatically
  54.     end
  55. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement