Advertisement
Guest User

Tree Script

a guest
Mar 27th, 2015
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.95 KB | None | 0 0
  1. local slots ={}
  2.  
  3. function plantTree()
  4.     turtle.select(1)
  5.     turtle.place()
  6. end
  7.  
  8. function chopTree()
  9.     turtle.select(4)
  10.     turtle.dig()
  11.     turtle.forward()
  12.     while turtle.detectUp() do
  13.         turtle.digUp()
  14.         turtle.up()
  15.     end
  16.     while not turtle.detectDown() do
  17.         turtle.down()
  18.     end
  19.     turtle.back()
  20. end
  21.  
  22. function hasTreeGrown()
  23.     turtle.select(3)
  24.     return turtle.compare()
  25. end
  26.  
  27. function bonemealTree()
  28.  
  29.     turtle.select(2)
  30.     turtle.place()
  31. end
  32.  
  33. function dropOffResources()
  34.     for i=4, 16, 1 do
  35.         turtle.select( i )
  36.         turtle.dropDown( 64 )
  37.     end
  38. end
  39.  
  40. function checkSlot( slot )
  41.     if turtle.getItemCount(2) == 0 then
  42.         if slots[ slot ] == true then
  43.             print( "Slot " + slot + " empty" )
  44.             slots[ slot ] = false
  45.         end
  46.     else
  47.         slots[ slot ] = true
  48.     end
  49. end
  50.  
  51. while true do
  52.     if hasTreeGrown() then
  53.         chopTree()
  54.         dropOffResources()
  55.     else
  56.         plantTree()
  57.         bonemealTree()
  58.     end
  59.     sleep(1)
  60.     checkSlot( 1 )
  61.     checkSlot( 2 )
  62.     checkSlot( 3 )
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement