Advertisement
Helium

Untitled treefarm

Jun 20th, 2013
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.56 KB | None | 0 0
  1. -- mark 2
  2.  
  3. function refuel()
  4.     if turtle.getFuelLevel() <= 1000 and turtle.getItemCount(16) > 0 then
  5.         turtle.select(16)
  6.         turtle.refuel()
  7.     end
  8.     turtle.select(1)
  9. end
  10.  
  11. function start()
  12.     turtle.select(1)
  13.     turtle.down()
  14.     turtle.dig()
  15.     turtle.forward()
  16. end
  17.  
  18. function firstline()
  19.     while turtle.digUp() do
  20.         turtle.dig()
  21.         turtle.up()
  22.     end
  23.     while turtle.detectDown() == false do
  24.         turtle.down()
  25.     end
  26. end
  27.  
  28. function secondline()
  29.     turtle.turnRight() 
  30.     turtle.dig()
  31.     turtle.forward()
  32.     turtle.turnLeft()
  33.     firstline()
  34. end
  35.  
  36. function dump()
  37.     turtle.back()
  38.     turtle.turnLeft()
  39.     turtle.turnLeft()
  40.     for slot = 1 , 14 do
  41.         turtle.select(slot)
  42.         turtle.drop()
  43.     end
  44. end
  45.  
  46. function checkfuel()
  47.     if turtle.getItemCount(16) == 0 then
  48.         turtle.turnLeft()
  49.         turtle.select(16)
  50.         turtle.suck()
  51.         turtle.turnRight()
  52.         turtle.turnRight()
  53.     else
  54.         turtle.turnRight()
  55.     end
  56. end
  57.  
  58. function checksap()
  59.     if turtle.getItemCount(15) <= 4 then
  60.         turtle.select(15)
  61.         turtle.forward()
  62.         turtle.suck()
  63.         turtle.back()
  64.         turtle.turnRight()
  65.     else
  66.         turtle.turnRight()
  67.     end
  68. end
  69.  
  70. function replant()
  71.     turtle.select(15)
  72.     turtle.forward()
  73.     turtle.place()
  74.     turtle.back()
  75.     turtle.place()
  76.     turtle.turnLeft()
  77.     turtle.forward()
  78.     turtle.turnRight()
  79.     turtle.forward()
  80.     turtle.place()
  81.     turtle.back()
  82.     turtle.place()
  83. end
  84.  
  85. function wait()
  86.     turtle.up()
  87.     while turtle.detect() == false do
  88.         sleep(5)
  89.     end
  90. end
  91.  
  92. function routine()
  93.     start()
  94.     refuel()
  95.     firstline()
  96.     secondline()
  97.     dump()
  98.     checkfuel()
  99.     checksap()
  100.     replant()
  101.     wait()
  102. end
  103.  
  104. while true do
  105.     routine()
  106. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement