bennyclams

Untitled

Aug 7th, 2026
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.56 KB | None | 0 0
  1. local rocket_drawer = peripheral.wrap("functionalstorage:oak_4_0")
  2. local warhead_drawer = peripheral.wrap("functionalstorage:oak_4_1")
  3. local controller = peripheral.find("mekmissiles:missile_silo")
  4. local message_display = peripheral.wrap("monitor_1")
  5.  
  6. local rocket_relay = peripheral.wrap("redstone_relay_5")
  7.  
  8. local small_warhead_relay = peripheral.wrap("redstone_relay_7")
  9. local medium_warhead_relay = peripheral.wrap("redstone_relay_6")
  10. local large_warhead_relay = peripheral.wrap("redstone_relay_9")
  11. local huge_warhead_relay = peripheral.wrap("redstone_relay_8")
  12.  
  13. local engine_item = "mekmissiles:rocket_engine"
  14. local body_item = "mekmissiles:rocket_body"
  15. local nose_item = "mekmissiles:rocket_nose_cone"
  16.  
  17. local small_warhead = "mnwe:industrial_bomb"
  18. local medium_warhead = "mnwe:nuclear_bomb"
  19. local large_warhead = "mnwe:hydrogen_bomb"
  20. local huge_warhead = "mnwe:antimatter_bomb"
  21.  
  22. function display_message(message, wait)
  23. if message_display then
  24. message_display.clear()
  25. message_display.setCursorPos(1, 1)
  26. message_display.write(message)
  27. else
  28. print("W: No message display found")
  29. print(message)
  30. end
  31. if wait then
  32. message_display.setCursorPos(1, 2)
  33. message_display.write("Press any button to continue...")
  34. os.pullEvent("redstone")
  35. os.sleep(1.1)
  36. end
  37. end
  38.  
  39. if not rocket_drawer then
  40. display_message("No rocket parts storage drawer found")
  41. return
  42. end
  43.  
  44. if not warhead_drawer then
  45. display_message("No warhead storage drawer found")
  46. return
  47. end
  48.  
  49. if not controller then
  50. display_message("No missile silo controller found")
  51. return
  52. end
  53.  
  54. ::begin::
  55.  
  56. controller.pushItems(peripheral.getName(warhead_drawer), 4)
  57. controller.pushItems(peripheral.getName(rocket_drawer), 3)
  58. controller.pushItems(peripheral.getName(rocket_drawer), 2)
  59. controller.pushItems(peripheral.getName(rocket_drawer), 1)
  60.  
  61. -- Wait for redstone signal to start assembly
  62. display_message("Rocket assembly system ready.")
  63. os.pullEvent("redstone")
  64. local relay_states = {
  65. rocket_relay.getInput("back"),
  66. small_warhead_relay.getInput("back"),
  67. medium_warhead_relay.getInput("back"),
  68. large_warhead_relay.getInput("back"),
  69. huge_warhead_relay.getInput("back")
  70. }
  71.  
  72. if relay_states[2] or relay_states[3] or relay_states[4] or relay_states[5] then
  73. display_message("Please assemble the rocket first, then select the warhead type.")
  74. goto begin
  75. end
  76.  
  77. local engine_slot = nil
  78. local body_slot = nil
  79. local nose_slot = nil
  80.  
  81. local small_warhead_slot = nil
  82. local medium_warhead_slot = nil
  83. local large_warhead_slot = nil
  84. local huge_warhead_slot = nil
  85.  
  86. for i = 1, rocket_drawer.size() do
  87. local item = rocket_drawer.getItemDetail(i)
  88. if item then
  89. if item.name == engine_item then
  90. engine_slot = i
  91. elseif item.name == body_item then
  92. body_slot = i
  93. elseif item.name == nose_item then
  94. nose_slot = i
  95. end
  96. end
  97. end
  98.  
  99. for i = 1, warhead_drawer.size() do
  100. local item = warhead_drawer.getItemDetail(i)
  101. if item then
  102. if item.name == small_warhead then
  103. small_warhead_slot = i
  104. elseif item.name == medium_warhead then
  105. medium_warhead_slot = i
  106. elseif item.name == large_warhead then
  107. large_warhead_slot = i
  108. elseif item.name == huge_warhead then
  109. huge_warhead_slot = i
  110. end
  111. end
  112. end
  113.  
  114. if not engine_slot then
  115. display_message("No rocket engine found in drawer", true)
  116. goto begin
  117. end
  118.  
  119. if not body_slot then
  120. display_message("No rocket body found in drawer", true)
  121. goto begin
  122. end
  123.  
  124. if not nose_slot then
  125. display_message("No rocket nose cone found in drawer", true)
  126. goto begin
  127. end
  128.  
  129. rocket_drawer.pushItems(peripheral.getName(controller), engine_slot, 1)
  130. rocket_drawer.pushItems(peripheral.getName(controller), body_slot, 1)
  131. rocket_drawer.pushItems(peripheral.getName(controller), nose_slot, 1)
  132.  
  133. ::warhead_selection::
  134. os.sleep(1.1)
  135. if not small_warhead_slot and not medium_warhead_slot and not large_warhead_slot and not huge_warhead_slot then
  136. display_message("No warheads found in drawer", true)
  137. goto begin
  138. end
  139.  
  140. display_message("Rocket assembled, please select the warhead type.")
  141.  
  142. os.pullEvent("redstone")
  143. relay_states = {
  144. rocket_relay.getInput("back"),
  145. small_warhead_relay.getInput("back"),
  146. medium_warhead_relay.getInput("back"),
  147. large_warhead_relay.getInput("back"),
  148. huge_warhead_relay.getInput("back")
  149. }
  150. os.sleep(1.1)
  151.  
  152. if relay_states[1] then
  153. display_message("Rocket already assembled, please select warhead.", true)
  154. goto warhead_selection
  155. end
  156.  
  157. local true_count = 0
  158. for i = 2, 5 do
  159. if relay_states[i] then
  160. true_count = true_count + 1
  161. end
  162. end
  163.  
  164. if true_count > 1 then
  165. display_message("Please select only one warhead type.")
  166. goto warhead_selection
  167. end
  168.  
  169. local selected_warhead_slot = nil
  170. if relay_states[2] then
  171. selected_warhead_slot = small_warhead_slot
  172. elseif relay_states[3] then
  173. selected_warhead_slot = medium_warhead_slot
  174. elseif relay_states[4] then
  175. selected_warhead_slot = large_warhead_slot
  176. elseif relay_states[5] then
  177. selected_warhead_slot = huge_warhead_slot
  178. end
  179.  
  180. if not selected_warhead_slot then
  181. print(textutils.serialize(relay_states))
  182. display_message("Selected warhead not found in drawer", true)
  183. goto warhead_selection
  184. end
  185.  
  186. warhead_drawer.pushItems(peripheral.getName(controller), selected_warhead_slot, 1)
  187. display_message("Warhead loaded into rocket.", true)
  188.  
  189. goto begin
  190.  
Advertisement
Add Comment
Please, Sign In to add comment