Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----BigReactor Control Installer
- -----by jaranvil aka jared314
- -----feel free to use and/or modify this code
- -----------------------------------------------
- --Run this program to install or update either reactor or turbine control programs.
- -----------------PASTEBINs--------------------------
- installer = "DR9Caqc2"
- reactor_control_pastebin = "2KMD9qkj"
- reactor_control_plus_pastebin = "ud3rKwmZ"
- reactor_control_plus2_pastebin = "aaGuHDXY"
- turbine_control_pastebin = "0BgkjFdX"
- reactor_startup = "AL8yGDAs"
- turbine_startup = "WGbnmxHx"
- reactor_update_check = "FJn4fUqD"
- turbine_update_check = "3b02GuZf"
- dev_installer = "EvF39HUJ"
- dev_reactor_control_pastebin = "xiEVEV9K"
- dev_turbine_control_pastebin = "ZJP4PNN3"
- ---------------------------------------------
- local reactor
- local turbine
- term.clear()
- -------------------FORMATTING-------------------------------
- function draw_text_term(x, y, text, text_color, bg_color)
- term.setTextColor(text_color)
- term.setBackgroundColor(bg_color)
- term.setCursorPos(x,y)
- write(text)
- end
- function draw_line_term(x, y, length, color)
- term.setBackgroundColor(color)
- term.setCursorPos(x,y)
- term.write(string.rep(" ", length))
- end
- function progress_bar_term(x, y, length, minVal, maxVal, bar_color, bg_color)
- draw_line_term(x, y, length, bg_color) --backgoround bar
- local barSize = math.floor((minVal/maxVal) * length)
- draw_line_term(x, y, barSize, bar_color) --progress so far
- end
- function menu_bars()
- draw_line_term(1, 1, 55, colors.blue)
- draw_text_term(10, 1, "BigReactors Control Installer", colors.white, colors.blue)
- draw_line_term(1, 19, 55, colors.blue)
- draw_text_term(10, 19, "by jaranvil aka jared314 & IDT", colors.white, colors.blue)
- end
- --------------------------------------------------------------
- function install(program, pastebin)
- term.clear()
- menu_bars()
- draw_text_term(1, 3, "Installing "..program.."...", colors.yellow, colors.black)
- term.setCursorPos(1,5)
- term.setTextColor(colors.white)
- sleep(0.5)
- -----------------Install control program---------------
- --delete any old backups
- if fs.exists(program.."_old") then
- fs.delete(program.."_old")
- end
- --remove old configs
- if fs.exists("config.txt") then
- fs.delete("config.txt")
- end
- --backup current program
- if fs.exists(program) then
- fs.copy(program, program.."_old")
- fs.delete(program)
- end
- --remove program and fetch new copy
- shell.run("pastebin get "..pastebin.." "..program)
- sleep(0.5)
- ------------------Install startup script-------------
- term.setCursorPos(1,8)
- --delete any old backups
- if fs.exists("startup_old") then
- fs.delete("startup_old")
- end
- --backup current program
- if fs.exists("startup") then
- fs.copy("startup", "startup_old")
- fs.delete("startup")
- end
- if program == "reactor_control" then
- shell.run("pastebin get "..reactor_startup.." startup")
- else if program == "turbine_control" then
- shell.run("pastebin get "..turbine_startup.." startup")
- end
- end
- if fs.exists(program) then
- draw_text_term(1, 11, "Success!", colors.lime, colors.black)
- draw_text_term(1, 12, "Press Enter to reboot...", colors.gray, colors.black)
- wait = read()
- shell.run("reboot")
- else
- draw_text_term(1, 11, "Error installing file.", colors.red, colors.black)
- sleep(0.1)
- draw_text_term(1, 12, "Restoring old file...", colors.gray, colors.black)
- sleep(0.1)
- fs.copy(program.."_old", program)
- fs.delete(program.."_old")
- draw_text_term(1, 14, "Press Enter to continue...", colors.gray, colors.black)
- wait = read()
- start()
- end
- end
- -- peripheral searching thanks to /u/kla_sch
- -- http://pastebin.com/gTEBHv3D
- function reactorSearch()
- local names = peripheral.getNames()
- local i, name
- for i, name in pairs(names) do
- if peripheral.getType(name) == "BigReactors-Reactor" then
- return peripheral.wrap(name)
- else
- --return null
- end
- end
- end
- function turbineSearch()
- local names = peripheral.getNames()
- local i, name
- for i, name in pairs(names) do
- if peripheral.getType(name) == "BigReactors-Turbine" then
- return peripheral.wrap(name)
- else
- --return null
- end
- end
- end
- function selectProgram()
- term.setBackgroundColor(colors.black)
- term.clear()
- menu_bars()
- draw_text_term(1, 4, "What would you like to install or update?", colors.yellow, colors.black)
- draw_text_term(3, 6, "1 - Reactor Control", colors.white, colors.black)
- draw_text_term(3, 7, "2 - Turbine Control", colors.white, colors.black)
- draw_text_term(3, 8, "3 - Reactor Control Bank (Direwolf20 1.7.10)", colors.white, colors.black)
- draw_text_term(3, 9, "4 - Reactor Control Bank (Space Astronomy 1.7.10)", colors.white, colors.black)
- draw_text_term(1, 10, "Enter 1, 2 or 3:", colors.yellow, colors.black)
- term.setCursorPos(1,11)
- term.setTextColor(colors.white)
- input = read()
- if input == "1" then
- install("reactor_control", reactor_control_pastebin)
- else if input == "2" then
- install("turbine_control", turbine_control_pastebin)
- else if input == "3" then
- install("reactor_control", reactor_control_plus_pastebin)
- else if input == "4" then
- install("reactor_control", reactor_control_plus2_pastebin)
- else if input == "dev1" then
- install("reactor_control", dev_reactor_control_pastebin)
- else if input == "dev2" then
- install("turbine_control", dev_turbine_control_pastebin)
- else
- draw_text_term(1, 12, "please enter a '1', '2' or '3'.", colors.red, colors.black)
- sleep(1)
- start()
- end
- end
- end
- end
- end
- end
- end
- function start()
- term.clear()
- menu_bars()
- selectProgram()
- end
- start()
Add Comment
Please, Sign In to add comment