Dodedodo33

Agriseed

Apr 17th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.40 KB | None | 0 0
  1. function forward(count)
  2.     for i=1,count do
  3.         turtle.forward()
  4.     end
  5. end
  6.  
  7. function left(count)
  8.     for i=1,count do
  9.         turtle.turnLeft()
  10.     end
  11. end
  12.  
  13. function right(count)
  14.     for i=1,count do
  15.         turtle.turnRight()
  16.     end
  17. end
  18.  
  19. function back(count)
  20.     for i=1,count do
  21.         turtle.back()
  22.     end
  23. end
  24.  
  25. function clearTerm()
  26.     term.clear()
  27.     term.setCursorPos(1,1)
  28. end
  29.  
  30. function isGrown()
  31.     local succes, data = turtle.inspectDown()
  32.     if succes then
  33.         if (data.metadata == 0) and (data.name == "Agriculture:crop") then
  34.             return true
  35.         end
  36.     end
  37.     return false
  38. end
  39.  
  40. function turnAround(toLeft)
  41.     if toLeft then
  42.         left(1)
  43.         forward(1)
  44.         left(1)
  45.     else
  46.         right(1)
  47.         forward(1)
  48.         right(1)
  49.     end
  50. end
  51.  
  52. function seed(width, height)
  53.     local firstRun = true
  54.     for i=1,2 do
  55.         turtle.up()
  56.         for x=1,width do
  57.             local noCorner = false
  58.             for y=1,height do
  59.                 if noCorner then
  60.                         forward(1)
  61.                 end
  62.                 if firstRun and (i == 2) then
  63.                     turtle.select(1)
  64.                     turtle.placeDown()
  65.                     turtle.select(16)
  66.                     turtle.placeDown()
  67.                     turtle.select(1)
  68.                     firstRun = false
  69.                 else
  70.                     turtle.placeDown()
  71.                 end
  72.                 noCorner = true
  73.             end
  74.             turnAround(x%2)
  75.         end
  76.     end
  77. end
  78.  
  79. clearTerm()
  80. print("Enter the desired height.")
  81. local height = tonumber(read())
  82. print("Enter the desired width.")
  83. local width = tonumber(read())
  84. clearTerm()
  85. print("Turtle will now initiate seeding.")
  86.  
  87. seed(width, height)
Advertisement
Add Comment
Please, Sign In to add comment