Advertisement
Plazter

Tree farm

Jun 25th, 2013
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.22 KB | None | 0 0
  1. function drop()
  2.  for i = 1,14 do
  3.   if turtle.getItemCount(i) > 0 then
  4.    turtle.select(i)
  5.    turtle.dropDown()
  6.   end
  7.  end
  8. end
  9.  
  10. function chop()
  11.  
  12. if turtle.detect() then
  13.  turtle.dig()
  14.  turtle.forward()
  15. end
  16.  
  17. while turtle.detectUp() do
  18.  turtle.digUp()
  19.  turtle.up()
  20. end
  21.  
  22. while not turtle.detectDown() do
  23.  turtle.down()
  24.  if turtle.detectDown() then
  25.   break
  26.  end
  27. end
  28.  
  29. turtle.back()
  30. end
  31.  
  32. function plant()
  33.  
  34. turtle.select(15) -- sapling
  35. turtle.place()
  36. sleep(2)
  37. turtle.select(16) -- bone meal
  38. turtle.place()
  39. turtle.select(1)
  40. end
  41.  
  42. function sapling()
  43.  if turtle.getItemCount(15) < 1 then
  44.   turtle.select(15)
  45.   turtle.turnRight()
  46.   turtle.suck()
  47.   turtle.turnLeft()
  48.   turtle.select(1)
  49.  end
  50. end
  51.  
  52. function bonemeal()
  53.  if turtle.getItemCount(16) < 1 then
  54.   turtle.select(16)
  55.   turtle.turnLeft()
  56.   turtle.suck()
  57.   turtle.turnRight()
  58.   turtle.select(1)
  59.  end
  60. end
  61.  
  62. function check()
  63. bonemeal()
  64. sapling()
  65. end
  66.  
  67. while true do
  68. term.clear()
  69. term.setCursorPos(1,1)
  70. print("enter Command!")
  71. input = read()
  72.  
  73. if input == "plant" then
  74. check()
  75. plant()
  76. end
  77.  
  78. if input == "chop" then
  79. chop()
  80. end
  81.  
  82. if input == "auto" then
  83.  while true do
  84.   check()
  85.   plant()
  86.   sleep(2)
  87.   chop()
  88.   drop()
  89.  end
  90. end
  91.  
  92. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement