Advertisement
Guest User

farm.lua

a guest
Dec 8th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.01 KB | None | 0 0
  1. function plant()
  2.  for i = 1, 8 do
  3.   turtle.placeDown()
  4.   turtle.forward()
  5.  end
  6.  turtle.placeDown()
  7. end
  8.  
  9. function harvest()
  10.  for i = 1, 8 do
  11.   turtle.digDown()
  12.   turtle.forward()
  13.  end
  14.  turtle.digDown()
  15. end
  16.  
  17. function comeback()
  18.  turtle.turnLeft()
  19.  for i = 1, 8 do
  20.   turtle.forward()
  21.  end
  22.  turtle.turnLeft()
  23.  for i = 1, 9 do
  24.   turtle.forward()
  25.  end
  26.  turtle.turnLeft()
  27.  turtle.turnLeft()
  28. end
  29.  
  30. function seed()
  31.  turtle.select(1)
  32.  turtle.suckDown(64)
  33.  turtle.suckDown(16)
  34.  turtle.forward()
  35.  for i = 1, 4 do
  36.   plant()
  37.   turtle.turnRight()
  38.   turtle.forward()
  39.   turtle.turnRight()
  40.   plant()
  41.   turtle.turnLeft()
  42.   turtle.forward()
  43.   turtle.turnLeft()
  44.   turtle.select(2)
  45.   turtle.transferTo(1,16)
  46.   turtle.select(1)
  47.  end
  48.  plant()
  49.  comeback()
  50. end
  51.  
  52. function click()
  53.  for i = 1, 4 do
  54.   turtle.placeDown()
  55.  end
  56. end
  57.  
  58. function bonemeal()
  59.  for i = 1, 8 do
  60.   click()
  61.   turtle.forward()
  62.  end
  63.  click()
  64. end
  65.  
  66. run = 0
  67.  
  68. k = 0
  69.  
  70. t = 0
  71.  
  72. while t == 0 do
  73.  if turtle.detectUp() == true and turtle.detectDown() == true and turtle.getItemCount(1) == 0 and turtle.getItemCount(2) == 0 then
  74.  t = 1
  75.  else if turtle.getItemCount(1) == 4 and turtle.getItemCount(2) == 4 and turtle.detectUp() == false and tuetle.detectDown() == false then
  76.     turtle.select(1)
  77.     turtle.placeUp()
  78.     turtle.placeDown()
  79.     turtle.turnLeft()
  80.     turtle.place()
  81.     turtle.turnRight()
  82.     turtle.turnRight()
  83.     turtle.place()
  84.     turtle.turnRight()
  85.     turtle.forward()
  86.     turtle.turnLeft()
  87.     turtle.forward()
  88.     turtle.turnLeft()
  89.     turtle.back()
  90.     turtle.select(2)
  91.     turtle.place("FUEL")
  92.     turtle.turnLeft()
  93.     turtle.forward()
  94.     turtle.forward()
  95.     turtle.turnRight()
  96.     turtle.place("BONEMEAL")
  97.     turtle.turnRight()
  98.     turtle.forward()
  99.     turtle.turnLeft()
  100.     turtle.down()
  101.     turtle.place("SEEDS")
  102.     turtle.up()
  103.     turtle.up()
  104.     turtle.place("PRODUCTS")
  105.     turtle.down()
  106.     turtle.forward()
  107.     turtle.forward()  
  108.     t = 1
  109.   else print("Chests and signs already placed")
  110.   else
  111.    term.getBackgroundColor(colors.blue)
  112.    print("Missing items!")
  113.    print("Plase put 4 chests and 4 sign to slot 1 and slot 2")
  114.    print("Then press Enter")
  115.    t = read()
  116.    if t == "" then t = 0 end
  117.   end
  118.  end
  119. end
  120. turtle.select(1)
  121. term.clear()
  122.  
  123. while true do
  124.  
  125. term.write("Round: ")
  126. run = read()
  127.  
  128. if turtle.getFuelLevel() <= run * 392 then
  129.  k = run * 392
  130.  k = k / 80
  131.  k = k + 1
  132.  turtle.turnRight()
  133.  turtle.suck(k)
  134.  turtle.refuel(k)
  135.  turtle.turnLeft()
  136. end
  137.  
  138. turtle.forward()
  139. for i = 1, 4 do
  140.  for i = 1,8 do
  141.   turtle.digDown()
  142.   turtle.forward()
  143.  end
  144.  turtle.digDown()
  145.  turtle.turnRight()
  146.  turtle.forward()
  147.  turtle.turnRight()
  148.  for i = 1, 8 do
  149.   turtle.digDown()
  150.   turtle.forward()
  151.  end
  152.  turtle.digDown()
  153.  turtle.turnLeft()
  154.  turtle.forward()
  155.  turtle.turnLeft()
  156. end
  157. for i = 1, 8 do
  158.  turtle.digDown()
  159.  turtle.forward()
  160. end
  161. turtle.digDown()
  162. comeback()
  163.  
  164. for i = 1, run do
  165.  seed()
  166.  os.sleep(1)
  167.  turtle.turnLeft()
  168.  turtle.select(1)
  169.  for i = 1, 4 do
  170.   turtle.suck(64)
  171.  end
  172.  turtle.turnRight()
  173.  turtle.forward()
  174.  for i = 1, 4 do
  175.   bonemeal()
  176.   turtle.turnRight()
  177.   turtle.forward()
  178.   turtle.turnRight()
  179.   bonemeal()
  180.   turtle.turnLeft()
  181.   turtle.forward()
  182.   turtle.turnLeft()
  183.   for i = 1, 4 do
  184.    turtle.select(i)
  185.    turtle.transferTo(1,64)
  186.   end
  187.   turtle.select(1)
  188.  end
  189.  bonemeal()
  190.  comeback()
  191.  turtle.turnLeft()
  192.  for i = 1, 4 do
  193.  turtle.select(i)
  194.  turtle.drop(64)
  195.  end
  196.  turtle.select(1)
  197.  turtle.turnRight()
  198.  turtle.forward()
  199.  for i = 1, 4 do
  200.    harvest()
  201.    turtle.turnRight()
  202.    turtle.forward()
  203.    turtle.turnRight()
  204.    harvest()
  205.    turtle.turnLeft()
  206.    turtle.forward()
  207.    turtle.turnLeft()
  208.  end
  209.  harvest()
  210.  comeback()
  211.  turtle.select(1)
  212.  turtle.dropUp(64)
  213.  turtle.select(5)
  214.  turtle.dropUp(64)
  215.  turtle.select(2)
  216.  turtle.dropDown(64)
  217.  turtle.select(3)
  218.  turtle.dropDown(64)
  219.  turtle.select(4)
  220.  turtle.dropDown(64)
  221.  turtle.select(6)
  222.  turtle.dropDown()
  223.  turtle.select(7)
  224.  turtle.dropDown()
  225. end
  226.  turtle.select(1)
  227.  term.clear()
  228.  
  229. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement