Advertisement
Guest User

farm.lua

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