Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. local component = require("component")
  2. local sides = require("sides")
  3. local robot = require("robot")
  4.  
  5. function turnRobot(turnedLeft)
  6. local turnedLeft = {}
  7. local movedBlocks = 0
  8. if (turnedLeft == 1)
  9. then
  10. robot.turnRight()
  11. while(movedBlocks < 3) do
  12. robot.swing(sides.front)
  13. robot.forward(1)
  14. movedBlocks = movedBlocks + 1
  15. end
  16. robot.turnRight()
  17. turnRobot = 0
  18. end
  19.  
  20. if (turnedLeft == 0)
  21. then
  22. robot.turnLeft()
  23. while( movedBlocks < 3) do
  24. robot.swing(sides.front)
  25. robot.forward(1)
  26. end
  27. robot.turnLeft()
  28. turnRobot = 1
  29. end
  30. return turnRobot;
  31. end
  32.  
  33. rmb = 1 -- Means Robot moved block
  34. turnedLeft = true -- Boolean that means at 1 that the robot turned left last 25 Blocks
  35.  
  36.  
  37. for i = 200,1,-1 do
  38. --Check when the Robot has moved 12 Blocks
  39. if (rmb % 12 == 0)
  40. then print("Es ist durch 12 teilbar")
  41. end
  42. if (rmb % 25 == 0)
  43. then turnedLeft = turnRobot(turnedLeft)
  44. print(turnedLeft)
  45. end
  46.  
  47.  
  48.  
  49. if robot.detect() == true
  50. then
  51. robot.swing(sides.front)
  52. robot.forward(1)
  53. print(rmb)
  54. else
  55. robot.forward(1)
  56. print(rmb)
  57. end
  58. rmb = rmb + 1
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement