bennyclams

Untitled

Aug 7th, 2026
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.46 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_8")
  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_7")
  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. end
  36. end
  37.  
  38. if not rocket_drawer then
  39. display_message("No rocket parts storage drawer found")
  40. return
  41. end
  42.  
  43. if not warhead_drawer then
  44. display_message("No warhead storage drawer found")
  45. return
  46. end
  47.  
  48. if not controller then
  49. display_message("No missile silo controller found")
  50. return
  51. end
  52.  
  53. ::begin::
  54.  
  55. controller.pushItems(peripheral.getName(warhead_drawer), 4)
  56. controller.pushItems(peripheral.getName(rocket_drawer), 3)
  57. controller.pushItems(peripheral.getName(rocket_drawer), 2)
  58. controller.pushItems(peripheral.getName(rocket_drawer), 1)
  59.  
  60. -- Wait for redstone signal to start assembly
  61. display_message("Rocket assembly system ready.")
  62. os.pullEvent("redstone")
  63. local relay_states = {
  64. rocket_relay.getInput("front"),
  65. small_warhead_relay.getInput("front"),
  66. medium_warhead_relay.getInput("front"),
  67. large_warhead_relay.getInput("front"),
  68. huge_warhead_relay.getInput("front")
  69. }
  70.  
  71. if relay_states[2] or relay_states[3] or relay_states[4] or relay_states[5] then
  72. display_message("Please assemble the rocket first, then select the warhead type.")
  73. goto begin
  74. end
  75.  
  76. local engine_slot = nil
  77. local body_slot = nil
  78. local nose_slot = nil
  79.  
  80. local small_warhead_slot = nil
  81. local medium_warhead_slot = nil
  82. local large_warhead_slot = nil
  83. local huge_warhead_slot = nil
  84.  
  85. for i = 1, rocket_drawer.size() do
  86. local item = rocket_drawer.getItemDetail(i)
  87. if item then
  88. if item.name == engine_item then
  89. engine_slot = i
  90. elseif item.name == body_item then
  91. body_slot = i
  92. elseif item.name == nose_item then
  93. nose_slot = i
  94. end
  95. end
  96. end
  97.  
  98. for i = 1, warhead_drawer.size() do
  99. local item = warhead_drawer.getItemDetail(i)
  100. if item then
  101. if item.name == small_warhead then
  102. small_warhead_slot = i
  103. elseif item.name == medium_warhead then
  104. medium_warhead_slot = i
  105. elseif item.name == large_warhead then
  106. large_warhead_slot = i
  107. elseif item.name == huge_warhead then
  108. huge_warhead_slot = i
  109. end
  110. end
  111. end
  112.  
  113. if not engine_slot then
  114. display_message("No rocket engine found in drawer", true)
  115. goto begin
  116. end
  117.  
  118. if not body_slot then
  119. display_message("No rocket body found in drawer", true)
  120. goto begin
  121. end
  122.  
  123. if not nose_slot then
  124. display_message("No rocket nose cone found in drawer", true)
  125. goto begin
  126. end
  127.  
  128. rocket_drawer.pushItems(peripheral.getName(controller), engine_slot, 1)
  129. rocket_drawer.pushItems(peripheral.getName(controller), body_slot, 1)
  130. rocket_drawer.pushItems(peripheral.getName(controller), nose_slot, 1)
  131.  
  132. ::warhead_selection::
  133.  
  134. if not small_warhead_slot and not medium_warhead_slot and not large_warhead_slot and not huge_warhead_slot then
  135. display_message("No warheads found in drawer", true)
  136. goto begin
  137. end
  138.  
  139. display_message("Rocket assembled, please select the warhead type.")
  140.  
  141. os.pullEvent("redstone")
  142. relay_states = {
  143. rocket_relay.getInput("front"),
  144. small_warhead_relay.getInput("front"),
  145. medium_warhead_relay.getInput("front"),
  146. large_warhead_relay.getInput("front"),
  147. huge_warhead_relay.getInput("front")
  148. }
  149.  
  150. if relay_states[1] then
  151. display_message("Rocket already assembled, please select the warhead type.")
  152. goto warhead_selection
  153. end
  154.  
  155. local true_count = 0
  156. for i = 2, 5 do
  157. if relay_states[i] then
  158. true_count = true_count + 1
  159. end
  160. end
  161.  
  162. if true_count > 1 then
  163. display_message("Please select only one warhead type.")
  164. goto warhead_selection
  165. end
  166.  
  167. local selected_warhead_slot = nil
  168. if relay_states[2] then
  169. selected_warhead_slot = small_warhead_slot
  170. elseif relay_states[3] then
  171. selected_warhead_slot = medium_warhead_slot
  172. elseif relay_states[4] then
  173. selected_warhead_slot = large_warhead_slot
  174. elseif relay_states[5] then
  175. selected_warhead_slot = huge_warhead_slot
  176. end
  177.  
  178. if not selected_warhead_slot then
  179. display_message("Selected warhead not found in drawer", true)
  180. goto warhead_selection
  181. end
  182.  
  183. warhead_drawer.pushItems(peripheral.getName(controller), selected_warhead_slot, 1)
  184. display_message("Warhead loaded into rocket.")
  185.  
  186.  
Advertisement
Add Comment
Please, Sign In to add comment