Broken_Fre

MyUpdater

Feb 19th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.49 KB | None | 0 0
  1. local turbinePastebinID = "878A8fVm"
  2. local reactorPastebinID = "MMb8tZZ6"
  3.  
  4. local type = 0
  5.  
  6. local function choise()
  7.   term.setTextColor(colors.yellow)
  8.   print("Which program do you want to install?")
  9.   print("1. Turbine")
  10.   print("2. Reactor")
  11.   while true do
  12.     term.setTextColor(colors.white)
  13.     local input = read()
  14.     if input == "1" then break end
  15.     if input == "2" then break end
  16.   end
  17.   type = tonumber(input)
  18.   print("")
  19. end
  20.  
  21. local function update(id)
  22.   term.setTextColor(colors.blue)
  23.   print("Downloading files...")
  24.   shell.run("pastebin", "get", id, "dl")
  25.  
  26.   local succes = shell.run("rename", "dl", "checked")
  27.   if succes == false then
  28.     term.setTextColor(colors.red)
  29.     print("\nFailed to download file!")
  30.   else
  31.     term.setTextColor(colors.green)
  32.     print("\nDownload succes!\n")
  33.     term.setTextColor(colors.blue)
  34.     print("Removing old files...")
  35.     shell.run("rm","startup")
  36.     term.setTextColor(colors.blue)
  37.     print("Renaming new files...\n")
  38.     shell.run("rename","checked","startup")
  39.     term.setTextColor(colors.green)
  40.     print("Update succes!")
  41.     while true do
  42.       term.setTextColor(colors.yellow)
  43.       print("Do you want to reboot now? (y/n)")
  44.       term.setTextColor(colors.white)
  45.       local input = read()
  46.       if input == "y" then  shell.run("reboot")
  47.       elseif input == "n" then break end
  48.     end
  49.    
  50.   end
  51. end
  52.  
  53.  
  54.  
  55.  
  56. term.setBackgroundColor(colors.black)
  57. term.clear()
  58. term.setCursorPos(1,1)
  59. local turbines = peripheral.find("BigReactors-Turbine")
  60. local reactor = peripheral.find("BigReactors-Reactor")
  61. if turbines ~= nil then
  62.   type = 2
  63. end
  64. if reactor ~= nil then
  65.   type = type + 1
  66. end
  67.  
  68.  
  69. term.setTextColor(colors.blue)
  70. print("Auto detect peripheral...\n")
  71. if type ~= 3 then
  72.   term.setTextColor(colors.green)
  73.   while true do
  74.     term.setTextColor(colors.yellow)
  75.     if type == 1 then
  76.       print("Reactor detected, confirm instalation? (y/n)")
  77.     elseif type == 2 then
  78.       print("Turbine detected, confirm instalation? (y/n)")
  79.     else
  80.       term.setTextColor(colors.red)
  81.       print("No peripheral found!\n")
  82.       choise()
  83.       break
  84.     end
  85.    
  86.     term.setTextColor(colors.white)
  87.     local input = read()
  88.     if input == "y" or input == "n"then break end
  89.   end
  90.   if input == "n" then
  91.     choise()
  92.   end
  93. else
  94.   term.setTextColor(colors.red)
  95.   print("Turbine AND Reactor detected!")
  96.   choise()
  97. end
  98.  
  99. if type == 1 then
  100.   update(reactorPastebinID)
  101. else
  102.   update(turbinePastebinID)
  103. end
Advertisement
Add Comment
Please, Sign In to add comment