Advertisement
Angelcastiel93

Untitled

Jan 27th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 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. scan()
  13. if r.swing() == true then
  14. repeat
  15. r.swing()
  16. until r.swing() == false
  17. else
  18. if r.forward() == true then
  19. x = x+1
  20. end
  21. end
  22. end
  23. end
  24.  
  25. function xdown()
  26. scan()
  27. while x > 1 do
  28. if r.swing() == true then
  29. repeat
  30. r.swing()
  31. until r.swing() == false
  32. else
  33. if r.forward() == true then
  34. x = x-1
  35. end
  36. end
  37. end
  38. end
  39.  
  40. function yup()
  41. scan()
  42. while yh < 4 do
  43. if r.swing() == true then
  44. repeat
  45. print("dig")
  46. r.swing()
  47. until r.swing() == false
  48. else
  49. if r.forward() == true then
  50. yh = yh+1
  51. y = y+1
  52. end
  53. end
  54. end
  55. yh = 1
  56. end
  57.  
  58. function drop()
  59. local selectedSlot = r.select()
  60. r.select(1)
  61. r.drop(r.count() - 1)
  62. r.select(2)
  63. r.drop(r.count() - 1)
  64. r.select(3)
  65. r.drop(r.count() - 1)
  66. print("drop")
  67. end
  68.  
  69. function scan()
  70. print("scan")
  71. if ge.analyze(1).hardness > 1.5 then
  72. r.swingUp(1)
  73. end
  74. if ge.analyze(0).hardness > 1.5 then
  75. r.swingDown(0)
  76. end
  77. if ge.analyze(4).hardness > 1.5 then
  78. r.turnRight()
  79. r.swing()
  80. r.turnLeft()
  81. end
  82. if ge.analyze(5).hardness > 1.5 then
  83. r.turnLeft()
  84. r.swing()
  85. r.turnRight()
  86. else
  87. print("pusto")
  88. end
  89.  
  90. end
  91. -- program main
  92.  
  93. while y < 41 do
  94. xup()
  95. r.turnRight()
  96. yup()
  97. drop()
  98. r.turnRight()
  99. xdown()
  100. r.turnLeft()
  101. yup()
  102. drop()
  103. r.turnLeft()
  104. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement