Advertisement
Guest User

harvest

a guest
Dec 27th, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | None | 0 0
  1. local width = 9
  2. local height = 9
  3.  
  4. function Left()
  5.   turtle.turnLeft()
  6.   turtle.forward()
  7.   turtle.turnLeft()
  8. end
  9.  
  10. function Right()
  11.   turtle.turnRight()
  12.   turtle.forward()
  13.   turtle.turnRight()
  14. end
  15.  
  16. function GoHome()
  17.   local result = height % 2
  18.  
  19.   if result == 1 then
  20.     for y = 1, height do
  21.       turtle.forward()
  22.     end
  23.  
  24.     turtle.turnRight()
  25.  
  26.     for x = 1, width do
  27.       turtle.forward()
  28.     end
  29.  
  30.     turtle.turnRight()
  31.   else
  32.     turtle.back()
  33.     turtle.turnLeft()
  34.  
  35.     for x = 1, width do
  36.       turtle.forward()
  37.     end
  38.  
  39.     turtle.turnRight()
  40.   end
  41. end
  42.  
  43. function Harvest()
  44.  
  45.   turtle.forward()
  46.  
  47.   for y = 1, height do  
  48.     for x = 1, width do
  49.       turtle.digDown()
  50.       turtle.suckDown()
  51.            
  52.       if x < width then
  53.         turtle.forward()
  54.       end
  55.     end
  56.  
  57.     local result = y % 2
  58.    
  59.     if result == 0 then
  60.       Left()
  61.     else
  62.       Right()
  63.     end
  64.   end
  65. end
  66.  
  67. function Dump()
  68.   for z = 1, 16 do
  69.     turtle.select(z)
  70.     turtle.dropDown()
  71.   end
  72. end
  73.  
  74. function Replant()
  75.   for i = 1, 16 do
  76.     turtle.suckUp(i)
  77.   end
  78.  
  79.   turtle.forward()
  80.    
  81.   for y = 1, height do
  82.     for x = 1, width do
  83.    
  84.       turtle.placeDown(1)  
  85.    
  86.       if x < width then
  87.         turtle.forward()
  88.       end
  89.     end
  90.    
  91.     local result = y % 2
  92.    
  93.     if result == 0 then
  94.       Left()
  95.     else
  96.       Right()
  97.     end
  98.    
  99.   end  
  100. end
  101.  
  102. Harvest()
  103. GoHome()
  104. Dump()
  105. sleep(15)
  106. Replant()
  107. GoHome()
  108. Dump()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement