Advertisement
Ni_Jay_Ni

ComputerCraft Farming Script

Jan 28th, 2019
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.10 KB | None | 0 0
  1. --[[ FARM program v0.3 ]]--
  2.  
  3. print("Please input how far forward the turtle should go...")
  4. y = io.read()
  5. print("Please input the number of columns there are...")
  6. x = io.read()
  7.  
  8. print("You should place the turtle at the X.")
  9. for rowsSample=0,y-1,1 do
  10.     print(string.rep('.',x))
  11. end
  12. print("X"..string.rep('.',x-1))
  13. print("Input Y to continue.")
  14. confirmation = io.read()
  15.  
  16. if confirmation ~= "Y" then
  17.     print("Cancelled farming...")
  18.     return
  19. end
  20.  
  21. alternating = false
  22. function alternateTurn()
  23.     if alternating then
  24.         turtle.turnLeft()
  25.         turtle.forward()
  26.         turtle.turnLeft()
  27.     else
  28.         turtle.turnRight()
  29.         turtle.forward()
  30.         turtle.turnRight()
  31.     end
  32. end
  33.  
  34. function checkCrop()
  35.     local exists, data = turtle.inspectDown()
  36.     if exists and data.name == "minecraft:wheat" and data.metadata == 7 then
  37.         turtle.digDown()
  38.         turtle.placeDown()
  39.     end
  40. end
  41.  
  42. for ax=1,x,1 do
  43.     for ay=1,y,1 do
  44.         checkCrop()
  45.         turtle.forward()
  46.     end
  47.     checkCrop()    
  48.     alternateTurn()
  49.     alternating = not alternating
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement