Advertisement
Superloup10

farm.lua

Jul 7th, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.78 KB | None | 0 0
  1. local robot = require("robot")
  2.  
  3. function moveToCharger()
  4.   robot.turnAround()
  5.   for i=1, 9 do
  6.     robot.forward()
  7.   end
  8.   robot.turnRight()
  9.   for i=1,8 do
  10.     robot.forward()
  11.   end
  12.   robot.turnRight()
  13. end
  14.  
  15. function plant()
  16.   robot.forward()
  17.   robot.useDown()
  18.   robot.swingDown()
  19.   robot.suckDown()
  20.   robot.placeDown()
  21. end
  22.  
  23. function plantRow()
  24.   for i=1,9 do
  25.     plant()
  26.   end
  27. end
  28.  
  29. function reverseRight()
  30.   robot.forward()
  31.   robot.turnRight()
  32.   robot.forward()
  33.   robot.turnRight()
  34. end
  35.  
  36. function reverseLeft()
  37.   robot.forward()
  38.   robot.turnLeft()
  39.   robot.forward()
  40.   robot.turnLeft()
  41. end
  42.  
  43. while true do
  44.   for i=1,4 do
  45.     plantRow()
  46.     reverseRight()
  47.     plantRow()
  48.     reverseLeft()
  49.   end
  50.   plantRow()
  51.   moveToCharger()
  52.   os.sleep(2400)
  53. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement