Advertisement
Guest User

Oak farm by Num

a guest
May 4th, 2013
2,572
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.10 KB | None | 0 0
  1. function moveDown()
  2.     while(not turtle.down()) do turtle.attackDown() end
  3. end
  4.  
  5. function moveUp()
  6.     while(not turtle.up()) do turtle.attackUp() end
  7. end
  8.  
  9. function moveForward()
  10.     while(not turtle.forward()) do turtle.attack() end
  11. end
  12.  
  13. function moveBack()
  14.     while(not turtle.back()) do sleep(1) end
  15. end
  16.  
  17. function prepPlant()
  18.     turtle.select(1)
  19.     moveForward()
  20.     turtle.suckDown()
  21.     moveForward()
  22.     turtle.suckDown()
  23.     moveBack()
  24.     moveBack()
  25.     if(turtle.getItemCount(1) < 64) then error("Not enough saplings.") end
  26.     if(turtle.getItemCount(2) < 64) then error("Not enough bonemeal.") end
  27. end
  28.  
  29. function plant()
  30.     moveBack()
  31.     turtle.select(1)
  32.     turtle.place()
  33.     turtle.select(2)
  34.     turtle.place()
  35. end
  36.  
  37. function plant7()
  38.     for i = 1,7 do
  39.         plant()
  40.     end
  41. end
  42.  
  43. function plant8x8()
  44.     for i = 1,4 do
  45.         plant7()
  46.         turtle.turnRight()
  47.         plant()
  48.         turtle.turnRight()
  49.         plant7()
  50.         turtle.turnLeft()
  51.         plant()
  52.         turtle.turnLeft()
  53.     end
  54. end
  55.  
  56. function harvest()
  57.     turtle.dig()
  58.     moveForward()
  59.     turtle.digUp()
  60.     turtle.digDown()
  61.     turtle.suckDown()
  62. end
  63.  
  64. function harvest7()
  65.     for i = 1,7 do
  66.         harvest()
  67.     end
  68. end
  69.  
  70. function harvest8x8()
  71.     for i = 1,4 do
  72.         harvest()
  73.         turtle.turnRight()
  74.         harvest7()
  75.         turtle.turnLeft()
  76.         harvest()
  77.         turtle.turnLeft()
  78.         harvest7()
  79.         turtle.turnRight()
  80.     end
  81. end
  82.  
  83. function prepHarvest()
  84.     turtle.select(1)
  85.     turtle.digUp()
  86.     moveUp()
  87.     turtle.turnRight()
  88. end
  89.  
  90. function to2ndLayer()
  91.     turtle.turnLeft()
  92.     turtle.dig()
  93.     moveForward()
  94.     for i = 1,3 do
  95.         turtle.digUp()
  96.         moveUp()
  97.     end
  98.     turtle.turnRight()
  99.     turtle.turnRight()
  100. end
  101.  
  102. function dropWood()
  103.     for i = 1,16 do
  104.         turtle.select(i)
  105.         turtle.dropDown()
  106.     end
  107. end
  108.  
  109. function toStartPoint()
  110.     turtle.turnLeft()
  111.     turtle.dig()
  112.     moveForward()
  113.     for i = 1,4 do
  114.         turtle.digDown()
  115.         moveDown()
  116.     end
  117.     turtle.turnLeft()
  118.     for i = 1,7 do
  119.         moveForward()
  120.     end
  121.     dropWood()
  122.     turtle.turnLeft()
  123.     moveForward()
  124.     turtle.turnRight()
  125. end
  126.  
  127. while(turtle.getFuelLevel() > 500) do
  128.     prepPlant()
  129.     plant8x8()
  130.     prepHarvest()
  131.     harvest8x8()
  132.     to2ndLayer()
  133.     harvest8x8()
  134.     toStartPoint()
  135. end
  136. print("Terminated: Low fuel level.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement