Advertisement
benjam123

Untitled

Nov 7th, 2020 (edited)
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.97 KB | None | 0 0
  1. -----By JAGS_BLAST
  2.  
  3. -----------------PASTEBINs--------------------------
  4. installer = "1wAMp1bC"
  5. reactor_control_pastebin = "vfEhs8qF"
  6. turbine_control_pastebin = "mvaPUCGz"
  7.  
  8. reactor_control_updater = "kB4k7BR7"
  9.  
  10. reactor_startup = "aSBDbNWs"
  11. turbine_startup = "v1n8TPXg"
  12.  
  13. reactor_update_check = "mDFM0Q6c"
  14. turbine_update_check = "QP3qrzNu"
  15.  
  16. dev_installer = "mCPQQ3Ge"
  17. dev_reactor_control_pastebin = "eYwBw9a3"
  18. dev_turbine_control_pastebin = "URDeSsV3"
  19. ---------------------------------------------
  20.  
  21. local reactor
  22. local turbine
  23. term.clear()
  24. -------------------FORMATTING-------------------------------
  25.  
  26. function draw_text_term(x, y, text, text_color, bg_color)
  27. term.setTextColor(text_color)
  28. term.setBackgroundColor(bg_color)
  29. term.setCursorPos(x,y)
  30. write(text)
  31. end
  32.  
  33. function draw_line_term(x, y, length, color)
  34. term.setBackgroundColor(color)
  35. term.setCursorPos(x,y)
  36. term.write(string.rep(" ", length))
  37. end
  38.  
  39. function progress_bar_term(x, y, length, minVal, maxVal, bar_color, bg_color)
  40. draw_line_term(x, y, length, bg_color) --backgoround bar
  41. local barSize = math.floor((minVal/maxVal) * length)
  42. draw_line_term(x, y, barSize, bar_color) --progress so far
  43. end
  44.  
  45. function menu_bars()
  46.  
  47. draw_line_term(1, 1, 55, colors.blue)
  48. draw_text_term(10, 1, "BigReactors Control Installer", colors.white, colors.blue)
  49.  
  50. draw_line_term(1, 19, 55, colors.blue)
  51. draw_text_term(10, 19, "by JAGS_BLAST", colors.white, colors.blue)
  52. end
  53.  
  54. --------------------------------------------------------------
  55.  
  56.  
  57.  
  58. function install(program, pastebin)
  59. term.clear()
  60. menu_bars()
  61.  
  62. draw_text_term(1, 3, "Installing "..program.."...", colors.yellow, colors.black)
  63. term.setCursorPos(1,5)
  64. term.setTextColor(colors.white)
  65. sleep(0.5)
  66.  
  67. -----------------Install control program---------------
  68.  
  69.  
  70. --delete any old backups
  71. if fs.exists(program.."_old") then
  72. fs.delete(program.."_old")
  73. end
  74.  
  75. --remove old configs
  76. if fs.exists("config.txt") then
  77. fs.delete("config.txt")
  78. end
  79.  
  80.  
  81. --remove old update checker
  82. if fs.exists("reactor_control_updater") then
  83. fs.delete("reactor_control_updater")
  84. end
  85. --install new update checker
  86. if program == "reactor_control" then
  87. shell.run("pastebin get "..reactor_control_updater.." reactor_control_updater")
  88. end
  89.  
  90. --backup current program
  91. if fs.exists(program) then
  92. fs.copy(program, program.."_old")
  93. fs.delete(program)
  94. end
  95.  
  96. --remove program and fetch new copy
  97.  
  98. shell.run("pastebin get "..pastebin.." "..program)
  99.  
  100. sleep(0.5)
  101.  
  102. ------------------Install startup script-------------
  103.  
  104. term.setCursorPos(1,8)
  105.  
  106. --delete any old backups
  107. if fs.exists("startup_old") then
  108. fs.delete("startup_old")
  109. end
  110.  
  111. --backup current program
  112. if fs.exists("startup") then
  113. fs.copy("startup", "startup_old")
  114. fs.delete("startup")
  115. end
  116.  
  117.  
  118. if program == "reactor_control" then
  119. shell.run("pastebin get "..reactor_startup.." startup")
  120. else if program == "turbine_control" then
  121. shell.run("pastebin get "..turbine_startup.." startup")
  122. end
  123. end
  124.  
  125. if fs.exists(program) then
  126. draw_text_term(1, 11, "Success!", colors.lime, colors.black)
  127. draw_text_term(1, 12, "Press Enter to reboot...", colors.gray, colors.black)
  128. wait = read()
  129. shell.run("reboot")
  130. else
  131. draw_text_term(1, 11, "Error installing file.", colors.red, colors.black)
  132. sleep(0.1)
  133. draw_text_term(1, 12, "Restoring old file...", colors.gray, colors.black)
  134. sleep(0.1)
  135. fs.copy(program.."_old", program)
  136. fs.delete(program.."_old")
  137.  
  138. draw_text_term(1, 14, "Press Enter to continue...", colors.gray, colors.black)
  139. wait = read()
  140. start()
  141. end
  142. end
  143.  
  144. function reactorSearch()
  145. local names = peripheral.getNames()
  146. local i, name
  147. for i, name in pairs(names) do
  148. if peripheral.getType(name) == "BigReactors-Reactor" then
  149. return peripheral.wrap(name)
  150. else
  151. --return null
  152. end
  153. end
  154. end
  155.  
  156. function turbineSearch()
  157. local names = peripheral.getNames()
  158. local i, name
  159. for i, name in pairs(names) do
  160. if peripheral.getType(name) == "BigReactors-Turbine" then
  161. return peripheral.wrap(name)
  162. else
  163. --return null
  164. end
  165. end
  166. end
  167.  
  168. function selectProgram()
  169. term.clear()
  170. menu_bars()
  171. draw_text_term(1, 4, "What would you like to install or update?", colors.yellow, colors.black)
  172. draw_text_term(3, 6, "1 - Reactor Control", colors.white, colors.black)
  173. draw_text_term(3, 7, "2 - Turbine Control", colors.white, colors.black)
  174. draw_text_term(1, 9, "Enter 1 or 2:", colors.yellow, colors.black)
  175.  
  176. term.setCursorPos(1,10)
  177. term.setTextColor(colors.white)
  178. input = read()
  179.  
  180. if input == "1" then
  181. install("reactor_control", reactor_control_pastebin)
  182. else if input == "2" then
  183. install("turbine_control", turbine_control_pastebin)
  184. else if input == "dev1" then
  185. install("reactor_control", dev_reactor_control_pastebin)
  186. else if input == "dev2" then
  187. install("turbine_control", dev_turbine_control_pastebin)
  188. else
  189. draw_text_term(1, 12, "please enter a '1' or '2'.", colors.red, colors.black)
  190. sleep(1)
  191. start()
  192. end
  193. end
  194. end
  195. end
  196. end
  197.  
  198. function start()
  199. term.clear()
  200. menu_bars()
  201.  
  202. if fs.exists("config.txt") then
  203.  
  204. if fs.exists("reactor_control") then
  205. draw_text_term(2, 3, "Current Program:", colors.white, colors.black)
  206. draw_text_term(2, 4, "Reactor Control", colors.lime, colors.black)
  207. draw_text_term(1, 6, "Do you want to update this program? (y/n)", colors.white, colors.black)
  208. draw_text_term(1, 7, "This will delete the current program and any saved settings", colors.gray, colors.black)
  209. term.setCursorPos(1,9)
  210. term.setTextColor(colors.white)
  211. input = read()
  212. if input == "y" then
  213. install("reactor_control", reactor_control_pastebin)
  214. else if input == "n" then
  215. selectProgram()
  216. else
  217. draw_text_term(1, 10, "please enter 'y' or 'n'.", colors.red, colors.black)
  218. sleep(1)
  219. start()
  220. end
  221. end
  222.  
  223. else if fs.exists("turbine_control") then
  224. draw_text_term(2, 3, "Current Program:", colors.white, colors.black)
  225. draw_text_term(2, 4, "Turbine Control", colors.lime, colors.black)
  226. draw_text_term(1, 6, "Do you want to update this program? (y/n)", colors.white, colors.black)
  227. draw_text_term(1, 7, "This will delete the current program and any saved settings", colors.gray, colors.black)
  228. term.setCursorPos(1,9)
  229. term.setTextColor(colors.white)
  230. input = read()
  231. if input == "y" then
  232. install("turbine_control", turbine_control_pastebin)
  233. else if input == "n" then
  234. selectProgram()
  235. else
  236. draw_text_term(1, 10, "please enter 'y' or 'n'.", colors.red, colors.black)
  237. sleep(1)
  238. start()
  239. end
  240. end
  241.  
  242. end
  243. end
  244. end
  245.  
  246. selectProgram()
  247.  
  248.  
  249. end
  250.  
  251. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement