Guest User

Untitled

a guest
Jul 15th, 2014
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. print("+-------------------------------------+")
  2. print("| Tree Farm made by Henkekalmar |")
  3. print("+-------------------------------------+")
  4. print("| |")
  5. print("| Before you start you must place a |")
  6. print("| chest with saplings on the turtle's |")
  7. print("| left side, and en empty chest under |")
  8. print("| it for emptying wood. |")
  9. print("| Place one log in the 2nd slot, fuel |")
  10. print("| in the 15th and a chest in the 16th |")
  11. print("| |")
  12. print("+-------------------------------------+")
  13. ---------------------------------------
  14. -- basic functions for turtle control -
  15. ---------------------------------------
  16. local function gf() while not turtle.forward() do end end
  17. local function gb() while not turtle.back() do end end
  18. local function gu() while not turtle.up() do end end
  19. local function gd() while not turtle.down() do end end
  20. local function gl() while not turtle.turnLeft() do end end
  21. local function gr() while not turtle.turnRight() do end end
  22. local function df() turtle.dig() end
  23. local function du() turtle.digUp() end
  24. local function dd() turtle.digDown() end
  25. local function pf() turtle.place() end
  26. local function pu() turtle.placeUp() end
  27. local function pd() turtle.placeDown() end
  28. local function sf() turtle.suck() end
  29. local function su() turtle.suckUp() end
  30. local function sd() turtle.suckDown() end
  31. local function Df() turtle.drop() end
  32. local function Du() turtle.dropUp() end
  33. local function Dd() turtle.dropDown() end
  34. local function ss(s) turtle.select(s) end
  35. ------Resetting itself 1.
  36. ss(2) if turtle.compare() then df() du() gu() else du() gu() end
  37. ss(2) if turtle.compare() then df() du() gu() end
  38. ss(2) if turtle.compare() then df() du() gu() end
  39. ss(2) if turtle.compare() then df() du() gu() end
  40. ss(2) if turtle.compare() then df() du() gu() end
  41. ss(2) if turtle.compare() then df() du() gu() end
  42. ss(2) if turtle.compare() then df() du() gu() end
  43. ss(2) if turtle.compare() then df() du() gu() end
  44. ------Resetting itself 2.
  45. gd() gd() gd() gd() gd() gd() gd() gd() gd() gd()
  46. ss(16) if turtle.compare() then os.sleep(0.2) else gr() end
  47. if turtle.compare() then os.sleep(0.2) else gr() end
  48. if turtle.compare() then os.sleep(0.2) else gr() end
  49. if turtle.compare() then os.sleep(0.2) else gr() end
  50. gr() ss(1) if turtle.detect() then os.sleep(0.2) else if pf() then os.sleep(0.2) else gl() sf(1) gr() pf() end end
  51. ------Detect growth/harvest
  52. while true do
  53. ss(1) if turtle.detect() then os.sleep(0.2) else if pf() then os.sleep(0.2) else gl() sf(1) gr() pf() end end
  54. ss(2) if turtle.compare() then df() gu() gu() du() df() gu() du() df()
  55. gu() du() df() gu() du() df() gu() du() df() gu() du() df() gu() df()
  56. gd() gd() gd() gd() gd() gd() gd() gd()
  57. ------Refuelling
  58. function checkFuel()
  59. if turtle.getFuelLevel() <= 200
  60. ss(15)
  61. turtle.refuel(1)
  62. end
  63. end
  64. ------Dropping off items
  65. ss(2) Dd(turtle.getItemCount(i) - 1)
  66. gl() ss(1) Df() ss(3) Df() ss(4) Df() ss(1) sf() Dd(turtle.getItemCount(i) - 4)
  67. ------
  68. end
  69. end
Advertisement
Add Comment
Please, Sign In to add comment