Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. local r = require("robot")
  2. local component = require("component")
  3. local ge = component.geolyzer
  4. local x = 1
  5. local y = 1
  6. local z = 1
  7. local yh = 1
  8. local g = component.generator
  9.  
  10. function xup()
  11. while x < 41 do
  12. if r.swing() == true then
  13. repeat
  14. r.swing()
  15. until r.swing() == false
  16. else
  17. if r.forward() == true then
  18. x = x+1
  19. end
  20. end
  21. end
  22. end
  23.  
  24. function xdown()
  25. while x > 1 do
  26. if r.swing() == true then
  27. repeat
  28. r.swing()
  29. until r.swing() == false
  30. else
  31. if r.forward() == true then
  32. x = x-1
  33. end
  34. end
  35. end
  36. end
  37.  
  38. function yup()
  39. while yh < 4 do
  40. if r.swing() == true then
  41. repeat
  42. print("dig")
  43. r.swing()
  44. until r.swing() == false
  45. else
  46. if r.forward() == true then
  47. yh = yh+1
  48. y = y+1
  49. print("y=")
  50. print(y)
  51. print("yh=")
  52. print(yh)
  53. end
  54. end
  55. end
  56. yh = 1
  57. print("y=")
  58. print(y)
  59. print("yh=")
  60. print(yh)
  61. end
  62.  
  63. -- program main
  64.  
  65. while y < 41 do
  66. xup()
  67. r.turnRight()
  68. yup()
  69. r.turnRight()
  70. xdown()
  71. r.tutnLeft()
  72. yup()
  73. r.turnLeft()
  74. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement