Advertisement
SolSkoll

[ARCHIVE] **BigReactors Installer**

Oct 2nd, 2024
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.55 KB | Gaming | 0 0
  1. -----THIS CODE WAS NOT CREATED BY THE UPLOADER. THE SOLE INTENTION OF THIS UPLOAD IS TO ARCHIVE WITH INTENT TO CONTINUE FUNCTION.
  2. -----ORIGINAL CODE WAS MADE IN 2014, AND FUNCTIONS TO THIS DAY FOR MINECRAFT 1.12.2, AND REQUIRES A PASTEBIN LINK TO INSTALL IN GAME
  3. -----SHOULD THE ORIGINAL CODE EVER CEASE TO EXIST, IT SHOULD HOPEFULLY SURVIVE AND REMAIN USABLE EVEN IF THE ORIGINAL DISSAPEARS.
  4. -----IN THE EVENT THE OTHER PASTEBINS CEASE TO FUNCTION, WAYBACK MACHINE SHOULD BE USED TO RECOVER THE OTHER CODES.
  5. -----THIS PASTE WILL ACT AS A HUB FOR THE REST OF THE INFORMATION TO BE RECOVERED IN CASE THE ORIGINAL PASTE IS LOST.
  6.  
  7. -----BigReactor Control Installer
  8. -----by jaranvil aka jared314
  9.  
  10. -----feel free to use and/or modify this code
  11. -----------------------------------------------
  12.  
  13.  
  14. --Run this program to install or update either reactor or turbine control programs.
  15.  
  16.  
  17. -----------------PASTEBINs--------------------------
  18. installer = "p4zeq7Ma"
  19. reactor_control_pastebin = "RCPEHmxs"
  20. turbine_control_pastebin = "5B8h94V4"
  21.  
  22. reactor_startup = "cZUH7y6k"
  23. turbine_startup = "h0jmye6t"
  24.  
  25. reactor_update_check = "MkF2QQjH"
  26. turbine_update_check = "QP3qrzNu"
  27.  
  28. dev_installer = "mCPQQ3Ge"
  29. dev_reactor_control_pastebin = "eYwBw9a3"
  30. dev_turbine_control_pastebin = "kJHeCx0Q"
  31. ---------------------------------------------
  32.  
  33. local reactor
  34. local turbine
  35. term.clear()
  36. -------------------FORMATTING-------------------------------
  37.  
  38. function draw_text_term(x, y, text, text_color, bg_color)
  39. term.setTextColor(text_color)
  40. term.setBackgroundColor(bg_color)
  41. term.setCursorPos(x,y)
  42. write(text)
  43. end
  44.  
  45. function draw_line_term(x, y, length, color)
  46. term.setBackgroundColor(color)
  47. term.setCursorPos(x,y)
  48. term.write(string.rep(" ", length))
  49. end
  50.  
  51. function progress_bar_term(x, y, length, minVal, maxVal, bar_color, bg_color)
  52. draw_line_term(x, y, length, bg_color) --backgoround bar
  53. local barSize = math.floor((minVal/maxVal) * length)
  54. draw_line_term(x, y, barSize, bar_color) --progress so far
  55. end
  56.  
  57. function menu_bars()
  58.  
  59. draw_line_term(1, 1, 55, colors.blue)
  60. draw_text_term(10, 1, "BigReactors Control Installer", colors.white, colors.blue)
  61.  
  62. draw_line_term(1, 19, 55, colors.blue)
  63. draw_text_term(10, 19, "by jaranvil aka jared314", colors.white, colors.blue)
  64. end
  65.  
  66. --------------------------------------------------------------
  67.  
  68.  
  69.  
  70. function install(program, pastebin)
  71. term.clear()
  72. menu_bars()
  73.  
  74. draw_text_term(1, 3, "Installing "..program.."...", colors.yellow, colors.black)
  75. term.setCursorPos(1,5)
  76. term.setTextColor(colors.white)
  77. sleep(0.5)
  78.  
  79. -----------------Install control program---------------
  80.  
  81.  
  82. --delete any old backups
  83. if fs.exists(program.."_old") then
  84. fs.delete(program.."_old")
  85. end
  86.  
  87. --remove old configs
  88. if fs.exists("config.txt") then
  89. fs.delete("config.txt")
  90. end
  91.  
  92. --backup current program
  93. if fs.exists(program) then
  94. fs.copy(program, program.."_old")
  95. fs.delete(program)
  96. end
  97.  
  98. --remove program and fetch new copy
  99.  
  100. shell.run("pastebin get "..pastebin.." "..program)
  101.  
  102. sleep(0.5)
  103.  
  104. ------------------Install startup script-------------
  105.  
  106. term.setCursorPos(1,8)
  107.  
  108. --delete any old backups
  109. if fs.exists("startup_old") then
  110. fs.delete("startup_old")
  111. end
  112.  
  113. --backup current program
  114. if fs.exists("startup") then
  115. fs.copy("startup", "startup_old")
  116. fs.delete("startup")
  117. end
  118.  
  119.  
  120. if program == "reactor_control" then
  121. shell.run("pastebin get "..reactor_startup.." startup")
  122. else if program == "turbine_control" then
  123. shell.run("pastebin get "..turbine_startup.." startup")
  124. end
  125. end
  126.  
  127. if fs.exists(program) then
  128. draw_text_term(1, 11, "Success!", colors.lime, colors.black)
  129. draw_text_term(1, 12, "Press Enter to reboot...", colors.gray, colors.black)
  130. wait = read()
  131. shell.run("reboot")
  132. else
  133. draw_text_term(1, 11, "Error installing file.", colors.red, colors.black)
  134. sleep(0.1)
  135. draw_text_term(1, 12, "Restoring old file...", colors.gray, colors.black)
  136. sleep(0.1)
  137. fs.copy(program.."_old", program)
  138. fs.delete(program.."_old")
  139.  
  140. draw_text_term(1, 14, "Press Enter to continue...", colors.gray, colors.black)
  141. wait = read()
  142. start()
  143. end
  144. end
  145.  
  146. -- peripheral searching thanks to /u/kla_sch
  147. -- http://pastebin.com/gTEBHv3D
  148. function reactorSearch()
  149. local names = peripheral.getNames()
  150. local i, name
  151. for i, name in pairs(names) do
  152. if peripheral.getType(name) == "BigReactors-Reactor" then
  153. return peripheral.wrap(name)
  154. else
  155. --return null
  156. end
  157. end
  158. end
  159.  
  160. function turbineSearch()
  161. local names = peripheral.getNames()
  162. local i, name
  163. for i, name in pairs(names) do
  164. if peripheral.getType(name) == "BigReactors-Turbine" then
  165. return peripheral.wrap(name)
  166. else
  167. --return null
  168. end
  169. end
  170. end
  171.  
  172. function selectProgram()
  173. term.clear()
  174. menu_bars()
  175. draw_text_term(1, 4, "What would you like to install or update?", colors.yellow, colors.black)
  176. draw_text_term(3, 6, "1 - Reactor Control", colors.white, colors.black)
  177. draw_text_term(3, 7, "2 - Turbine Control", colors.white, colors.black)
  178. draw_text_term(1, 9, "Enter 1 or 2:", colors.yellow, colors.black)
  179.  
  180. term.setCursorPos(1,10)
  181. term.setTextColor(colors.white)
  182. input = read()
  183.  
  184. if input == "1" then
  185. install("reactor_control", reactor_control_pastebin)
  186. else if input == "2" then
  187. install("turbine_control", turbine_control_pastebin)
  188. else if input == "dev1" then
  189. install("reactor_control", dev_reactor_control_pastebin)
  190. else if input == "dev2" then
  191. install("turbine_control", dev_turbine_control_pastebin)
  192. else
  193. draw_text_term(1, 12, "please enter a '1' or '2'.", colors.red, colors.black)
  194. sleep(1)
  195. start()
  196. end
  197. end
  198. end
  199. end
  200. end
  201.  
  202. function start()
  203. term.clear()
  204. menu_bars()
  205.  
  206. if fs.exists("config.txt") then
  207.  
  208. if fs.exists("reactor_control") then
  209. draw_text_term(2, 3, "Current Program:", colors.white, colors.black)
  210. draw_text_term(2, 4, "Reactor Control", colors.lime, colors.black)
  211. draw_text_term(1, 6, "Do you want to update this program? (y/n)", colors.white, colors.black)
  212. draw_text_term(1, 7, "This will delete the current program and any saved settings", colors.gray, colors.black)
  213. term.setCursorPos(1,9)
  214. term.setTextColor(colors.white)
  215. input = read()
  216. if input == "y" then
  217. install("reactor_control", reactor_control_pastebin)
  218. else if input == "n" then
  219. selectProgram()
  220. else
  221. draw_text_term(1, 10, "please enter 'y' or 'n'.", colors.red, colors.black)
  222. sleep(1)
  223. start()
  224. end
  225. end
  226.  
  227. else if fs.exists("turbine_control") then
  228. draw_text_term(2, 3, "Current Program:", colors.white, colors.black)
  229. draw_text_term(2, 4, "Turbine Control", colors.lime, colors.black)
  230. draw_text_term(1, 6, "Do you want to update this program? (y/n)", colors.white, colors.black)
  231. draw_text_term(1, 7, "This will delete the current program and any saved settings", colors.gray, colors.black)
  232. term.setCursorPos(1,9)
  233. term.setTextColor(colors.white)
  234. input = read()
  235. if input == "y" then
  236. install("turbine_control", turbine_control_pastebin)
  237. else if input == "n" then
  238. selectProgram()
  239. else
  240. draw_text_term(1, 10, "please enter 'y' or 'n'.", colors.red, colors.black)
  241. sleep(1)
  242. start()
  243. end
  244. end
  245.  
  246. end
  247. end
  248. end
  249.  
  250. selectProgram()
  251.  
  252.  
  253. end
  254.  
  255. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement