Advertisement
ns09005264

rockfarm.lua

Feb 5th, 2019
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. local component = require("component")
  2. local os = require("os")
  3. local robot = require("robot")
  4.  
  5. local LENGTH = 12
  6. local SLEEP_TIME = 40
  7.  
  8. function forward()
  9. while not robot.forward() do
  10. os.sleep(1)
  11. end
  12. end
  13.  
  14. function replaceStone()
  15. robot.swingDown()
  16. robot.placeDown()
  17. end
  18.  
  19. while true do
  20. forward()
  21.  
  22. --Row 1
  23. for i=1,LENGTH do
  24. replaceStone()
  25. if i ~=LENGTH then forward() end
  26. end
  27.  
  28. --Row 2
  29. robot.turnRight()
  30. forward()
  31. robot.turnRight()
  32. for i=1,LENGTH/3 do
  33. replaceStone()
  34. forward()
  35. forward()
  36. replaceStone()
  37. if i ~= LENGTH/3 then forward() end
  38. end
  39.  
  40. --Row 3
  41. robot.turnLeft()
  42. forward()
  43. robot.turnLeft()
  44. for i=1,LENGTH do
  45. replaceStone()
  46. if i ~= LENGTH then forward() end
  47. end
  48.  
  49. -- Return
  50. robot.turnLeft()
  51. for i=1,2 do forward() end
  52. robot.turnLeft()
  53. for i=1,LENGTH do forward() end
  54. robot.turnRight()
  55. robot.turnRight()
  56.  
  57. os.sleep(SLEEP_TIME)
  58. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement