Thor_s_Crafter

installer

Feb 9th, 2016
8,721
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.43 KB | None | 0 0
  1. -- Reactor- und Turbine control by Thor_s_Crafter --
  2. -- Version 2.3 --
  3. -- Installer (Deutsch) --
  4.  
  5. --Loads the option file if not present yet
  6. if not fs.exists("/reactor-turbine-program/config/options.txt") then
  7.   shell.run("pastebin get KFcHD2Bj /reactor-turbine-program/config/options.txt")
  8. end
  9.  
  10. --Reads the version --Currently deprecated
  11. local optionList = {}
  12. file = fs.open("/reactor-turbine-program/config/options.txt","r")
  13. listElement = file.readLine()
  14. while listElement do
  15.   table.insert(optionList,listElement)
  16.   listElement = file.readLine()
  17. end
  18. file.close()
  19.  
  20. local version = optionList[3]
  21. local nVersion = 2.3
  22.  
  23. --Update?
  24. if fs.exists("/reactor-turbine-program/program/turbineControl.lua") then
  25.   update = true
  26. else update = false
  27. end
  28.  
  29. --First time installation
  30. if not update then
  31.   --Description
  32.   term.clear()
  33.   term.setCursorPos(1,1)
  34.   print("Reaktor- und Turbinenprogramm von Thor_s_Crafter")
  35.   print("Version 2.3")
  36.   print()
  37.   print("Ueber das Programm:")
  38.   print("Das Programm kontrolliert einen BigReactors-Reaktor.")
  39.   print("Es koennen auch bis zu 32 Turbinen angeschlossen werden.")
  40.   print("Der Computer muss mit Wired Modems am Reaktor (und ggf. Turbinen) verbunden werden.")
  41.   print("Ausserdem muss ein Energiespeicher und ein Monitor angeschlossen werden.")
  42.   print("Der Monitor muss min. 7 Bloecke breit und 4 Bloecke hoch sein.")
  43.   print("Wird das Programm mit Turbinen betrieben, sollte der Reaktor pro Turbine mindestens 2000mb/t Steam produzieren koennen.")
  44.   print()
  45.   write("Bitte Enter druecken...")
  46.   leer = read()
  47.  
  48.   --Computer label
  49.   local out = true
  50.   while out do
  51.     term.clear()
  52.     term.setCursorPos(1,1)
  53.     print("Es wird empfohlen den Computer zu labeln.")
  54.     term.write("Computer labeln? (j/n): ")
  55.  
  56.     local input = read()
  57.     if input == "j" then
  58.       print()
  59.       shell.run("label set \"TurbineComputer\"")
  60.       print()
  61.       print("ComputerLabel auf \"TurbineComputer\" gesetzt.")
  62.       print()
  63.       sleep(2)
  64.       out = false
  65.  
  66.     elseif input == "n" then
  67.       print()
  68.       print("ComputerLabel wurde nicht gesetzt.")
  69.       print()
  70.       out = false
  71.     end
  72.   end
  73.  
  74.   --Startup
  75.   local out2 = true
  76.   while out2 do
  77.     term.clear()
  78.     term.setCursorPos(1,1)
  79.     print("Es wird empfohlen das Programm zum Startup hinzuzufugen.")
  80.     print("Dadurch wird das Programm beim Starten des Computers automatisch ausgefuehrt.")
  81.     term.write("Startup hinzufuegen? (j/n): ")
  82.  
  83.     local input = read()
  84.     if input == "j" then
  85.       local file = fs.open("startup","w")
  86.       file.writeLine("shell.run(\"/reactor-turbine-program/start/start.lua\")")
  87.       file.close()
  88.       print()
  89.       print("Startup wurde installiert.")
  90.       print()
  91.       out2 = false
  92.     end
  93.     if input == "n" then
  94.       print()
  95.       print("Startup wurde nicht installiert.")
  96.       print()
  97.       out2 = false
  98.     end
  99.   end
  100.  
  101.   sleep(1)
  102. end --update
  103.  
  104. term.clear()
  105. term.setCursorPos(1,1)
  106.  
  107. print("Checke und loesche vorhandene Programme...")
  108. --Removes input.lua and touchpoint.lua
  109. if fs.exists("/reactor-turbine-program/config/input.lua") then
  110.   shell.run("rm /reactor-turbine-program/config/input.lua")
  111. end
  112. if fs.exists("/reactor-turbine-program/config/touchpoint.lua") then
  113.   shell.run("rm /reactor-turbine-program/config/touchpoint.lua")
  114. end
  115. --Removes the program folder
  116. if fs.exists("/reactor-turbine-program/program/") then
  117.   shell.run("rm /reactor-turbine-program/program/")
  118. end
  119. --Removes the start folder
  120. if fs.exists("/reactor-turbine-program/start/") then
  121.   shell.run("rm /reactor-turbine-program/start/")
  122. end
  123. --Removes the changelog folder
  124. if fs.exists("/reactor-turbine-program/changelog/") then
  125.   shell.run("rm /reactor-turbine-program/changelog/")
  126. end
  127.  
  128. --Download all program parts
  129. print("Lade neue Programmteile...")
  130. shell.run("pastebin get yszvvGGG /reactor-turbine-program/config/input.lua")
  131. shell.run("pastebin get yTXVvQ4s /reactor-turbine-program/config/touchpoint.lua")
  132. shell.run("pastebin get NwHaeCzh /reactor-turbine-program/program/editOptions.lua")
  133. shell.run("pastebin get KjwASAn2 /reactor-turbine-program/program/reactorControl.lua")
  134. shell.run("pastebin get KdnLB5bx /reactor-turbine-program/program/turbineControl.lua")
  135. shell.run("pastebin get 4jRyfMz7 /reactor-turbine-program/start/menu.lua")
  136. shell.run("pastebin get uLQCLcV9 /reactor-turbine-program/start/start.lua")
  137. shell.run("pastebin get 3DLAa2HE /reactor-turbine-program/changelog/changelogDe.txt")
  138. shell.run("pastebin get h1G9tH7y /reactor-turbine-program/changelog/changelogEn.txt")
  139. print("Fertig!")
  140.  
  141. term.clear()
  142. term.setCursorPos(1,1)
  143.  
  144. --Refresh startup (if installed)
  145. if fs.exists("startup") then
  146.   shell.run("delete startup")
  147.   local file = fs.open("startup","w")
  148.   file.writeLine("shell.run(\"/reactor-turbine-program/start/start.lua\")")
  149.   file.close()
  150. end
  151.  
  152. --Install complete
  153. term.clear()
  154. term.setCursorPos(1,1)
  155.  
  156. if not update then
  157.   print("Die Installation wurde erfolgreich abgeschlossen!")
  158.   print("Das Programm ist nun einsatzbereit!")
  159.   print()
  160.   term.setTextColor(colors.yellow)
  161.   print("Beim ersten Start ist es notwendig den Computer manuell neu zu starten!")
  162.   print("Dazu bitte \"reboot\" eingeben oder \"Strg + R\" kurz gedrueckt halten.")
  163.   term.setTextColor(colors.white)
  164.   print()
  165.   print("Danke, dass du mein Programm benutzt! ;)")
  166.   print("Viel Spass damit.")
  167.   print("(Thor_s_Crafter)")
  168.   print()
  169. end
  170. error("Installer beendet. (Das ist kein Fehler! Bitte ignorieren!)")
Advertisement
Add Comment
Please, Sign In to add comment