Guest User

Untitled

a guest
Aug 14th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. --Bridge Segment building robot program
  2.  
  3. local sides = require("sides")
  4. local event = require("event")
  5. local c = require("component")
  6. local computer = require("computer")
  7. local robot = c.robot
  8. local rs = c.redstone
  9. local chu = c.chunkloader
  10.  
  11. local function moveUp(amount)
  12. local move = amount
  13.  
  14. while move > 0 do
  15. robot.move(sides.up)
  16. move = move - 1
  17. end
  18. end
  19.  
  20. local function moveDown(amount)
  21. local move = amount
  22.  
  23. while move > 0 do
  24. robot.move(sides.down)
  25. move = move - 1
  26. end
  27. end
  28.  
  29. local function moveLeft(amount)
  30. local move = amount
  31.  
  32. robot.turn(false)
  33.  
  34. while move > 0 do
  35. robot.move(sides.front)
  36. move = move - 1
  37. end
  38.  
  39. robot.turn(true)
  40. end
  41.  
  42. local function moveRight(amount)
  43. local move = amount
  44. robot.turn(true)
  45.  
  46. while move > 0 do
  47. robot.move(sides.front)
  48. move = move - 1
  49. end
  50. robot.turn(false)
  51. end
  52.  
  53. local function moveForward(amount)
  54. local move = amount
  55.  
  56. while move > 0 do
  57. robot.move(sides.front)
  58. move = move - 1
  59. end
  60. end
  61.  
  62. local function moveBack(amount)
  63. local move = amount
  64.  
  65. while move > 0 do
  66. robot.move(sides.back)
  67. move = move - 1
  68. end
  69. end
  70.  
  71. local function oneeighty()
  72. robot.turn(true)
  73. robot.turn(true)
  74. end
  75.  
  76. local function place()
  77. robot.place(sides.front)
  78. end
  79.  
  80. local function doplace()
  81. place()
  82. oneeighty()
  83. place()
  84. oneeighty()
  85. end
  86.  
  87. robot.select(1)
  88. robot.setLightColor(0x00DB00) --green
  89. doplace()
  90. moveUp(1)
  91. doplace()
  92. moveUp(1)
  93. doplace()
  94. moveLeft(1) -- Left supporting arm
  95. doplace()
  96. moveLeft(1)
  97. doplace()
  98. moveLeft(1)
  99. doplace()
  100. moveLeft(1)
  101. doplace()
  102. moveUp(1)
  103. doplace()
  104. moveUp(1)
  105. doplace()
  106. moveLeft(1) -- Leftmost track support
  107. doplace()
  108. moveLeft(1)
  109. doplace()
  110. moveLeft(1)
  111. doplace()
  112. moveLeft(1)
  113. doplace()
  114. moveRight(5) -- Left track support
  115. doplace()
  116. moveRight(1)
  117. doplace()
  118. moveRight(1)
  119. doplace()
  120. robot.select(2)
  121. moveRight(1)
  122. doplace()
  123. moveDown(1)
  124. doplace()
  125. moveDown(1)
  126. moveRight(1) -- Right supporting arm
  127. doplace()
  128. moveRight(1)
  129. doplace()
  130. moveRight(1)
  131. doplace()
  132. moveRight(1)
  133. doplace()
  134. moveUp(1)
  135. doplace()
  136. moveUp(1)
  137. doplace()
  138. moveRight(1) -- Rightmost track support
  139. doplace()
  140. moveRight(1)
  141. doplace()
  142. moveRight(1)
  143. doplace()
  144. moveRight(1)
  145. doplace()
  146. moveLeft(5) -- Right track support
  147. doplace()
  148. moveLeft(1)
  149. doplace()
  150. moveLeft(1)
  151. doplace()
  152. moveLeft(1)
  153. doplace()
  154. moveUp(1) -- Place final post in the center and stop
  155. robot.place(sides.down)
  156. robot.setLightColor(0xFF0000) --red
  157. computer.shutdown()
Advertisement
Add Comment
Please, Sign In to add comment