Jo__2001__Bo

CC Tweaked Reactor Control Wireless Installer

Dec 13th, 2020 (edited)
1,392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.91 KB | None | 0 0
  1. -----------------PASTEBINs--------------------------
  2. installer = "fWnhLdRx"
  3. reactor_control_server_pastebin = "v1p9TQaV"
  4. reactor_control_client_pastebin = "wCYyVaPf"
  5. ---------------------------------------------
  6. term.clear()
  7. -------------------FORMATTING-------------------------------
  8.  
  9. function draw_text_term(x, y, text, text_color, bg_color)
  10.   term.setTextColor(text_color)
  11.   term.setBackgroundColor(bg_color)
  12.   term.setCursorPos(x,y)
  13.   write(text)
  14. end
  15.  
  16. function draw_line_term(x, y, length, color)
  17.     term.setBackgroundColor(color)
  18.     term.setCursorPos(x,y)
  19.     term.write(string.rep(" ", length))
  20. end
  21.  
  22. function progress_bar_term(x, y, length, minVal, maxVal, bar_color, bg_color)
  23.   draw_line_term(x, y, length, bg_color) --backgoround bar
  24.   local barSize = math.floor((minVal/maxVal) * length)
  25.   draw_line_term(x, y, barSize, bar_color)  --progress so far
  26. end
  27.  
  28. function menu_bars()
  29.  
  30.   draw_line_term(1, 1, 55, colors.blue)
  31.   draw_text_term(10, 1, "BigReactors Wireless Control Installer", colors.white, colors.blue)
  32.  
  33.   draw_line_term(1, 19, 55, colors.blue)
  34.   draw_text_term(10, 19, "by Johannes aka JO__2001__BO", colors.white, colors.blue)
  35. end
  36.  
  37. --------------------------------------------------------------
  38.  
  39.  
  40.  
  41. function install(pastebin)
  42.   term.clear()
  43.   menu_bars()
  44.  
  45.   draw_text_term(1, 3, "Installing...", colors.yellow, colors.black)
  46.   term.setCursorPos(1,5)
  47.   term.setTextColor(colors.white)
  48.   sleep(0.5)
  49.  
  50.   -----------------Install control program---------------
  51.  
  52.   shell.run("pastebin get "..pastebin.." startup")
  53.  
  54.   sleep(0.5)
  55.  
  56.   ------------------Install startup script-------------
  57.  
  58.   if fs.exists("startup") then
  59.     draw_text_term(1, 11, "Success!", colors.lime, colors.black)
  60.     draw_text_term(1, 12, "Press Enter to reboot...", colors.gray, colors.black)
  61.     wait = read()
  62.     shell.run("reboot")
  63.   else
  64.     draw_text_term(1, 11, "Error installing file.", colors.red, colors.black)
  65.     sleep(0.1)
  66.     draw_text_term(1, 14, "Press Enter to continue...", colors.gray, colors.black)
  67.     wait = read()
  68.     start()
  69.   end
  70. end
  71.  
  72. function selectProgram()
  73.   term.clear()
  74.   menu_bars()
  75.   draw_text_term(1, 4, "What would you like to install or update?", colors.yellow, colors.black)
  76.   draw_text_term(3, 6, "1 - Reactor Control Client", colors.white, colors.black)
  77.   draw_text_term(3, 7, "2 - Reactor Control Server", colors.white, colors.black)
  78.   draw_text_term(1, 9, "Enter 1 or 2:", colors.yellow, colors.black)
  79.  
  80.   term.setCursorPos(1,10)
  81.   term.setTextColor(colors.white)
  82.   input = read()
  83.  
  84.   if input == "1" then
  85.     install(reactor_control_client_pastebin)
  86.   else if input == "2" then
  87.     install(reactor_control_server_pastebin)
  88.   else
  89.     draw_text_term(1, 12, "please enter a '1' or '2'.", colors.red, colors.black)
  90.     sleep(1)
  91.     start()
  92.   end
  93.   end
  94. end
  95.  
  96. function start()
  97.   term.clear()
  98.   menu_bars()
  99.   selectProgram()
  100.  
  101.  
  102. end
  103.  
  104. start()
Add Comment
Please, Sign In to add comment