GLaDOS446

BASE STARTUP

Jun 20th, 2026
88
0
Never
4
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.28 KB | Source Code | 0 0
  1. -- Konfiguration & Pfade
  2. local CONFIG_FILE = ".sys_config"
  3. local redstone_side = "back" -- Seite, an der Project Red Kabel hängen
  4.  
  5. -- System-Status (wird zur Laufzeit gehalten)
  6. local sys_config = {
  7. adminCreated = false,
  8. adminName = "",
  9. adminPass = "",
  10. users = {},
  11. systemsActive = false
  12. }
  13.  
  14. -- Helfer: Konfiguration laden
  15. local function loadConfig()
  16. if fs.exists(CONFIG_FILE) then
  17. local f = fs.open(CONFIG_FILE, "r")
  18. local data = f.readAll()
  19. f.close()
  20. sys_config = textutils.unserialize(data) or sys_config
  21. end
  22. end
  23.  
  24. -- Helfer: Konfiguration speichern
  25. local function saveConfig()
  26. local f = fs.open(CONFIG_FILE, "w")
  27. f.write(textutils.serialize(sys_config))
  28. f.close()
  29. end
  30.  
  31. -- Grafischer Helfer: Bildschirm leeren mit Hintergrundfarbe
  32. local function clearScreen(bgColor, textColor)
  33. term.setBackgroundColor(bgColor or colors.gray)
  34. term.setTextColor(textColor or colors.white)
  35. term.clear()
  36. term.setCursorPos(1,1)
  37. end
  38.  
  39. -- Grafischer Helfer: Zentrierter Text
  40. local function printCentered(y, text, bgColor, textColor)
  41. local w, h = term.getSize()
  42. local x = math.floor((w - #text) / 2) + 1
  43. term.setCursorPos(x, y)
  44. if bgColor then term.setBackgroundColor(bgColor) end
  45. if textColor then term.setTextColor(textColor) end
  46. term.write(text)
  47. end
  48.  
  49. -- Grafischer Helfer: Ladebalken
  50. local function drawProgressBar(y, progress, max)
  51. local w, h = term.getSize()
  52. local barWidth = w - 10
  53. local filled = math.floor((progress / max) * barWidth)
  54.  
  55. term.setCursorPos(6, y)
  56. term.setBackgroundColor(colors.lightGray)
  57. term.write(string.rep(" ", barWidth))
  58.  
  59. term.setCursorPos(6, y)
  60. term.setBackgroundColor(colors.lime)
  61. term.write(string.rep(" ", filled))
  62. end
  63.  
  64. -- 1. DER BOOT-VORGANG
  65. local function bootSequence()
  66. clearScreen(colors.black, colors.cyan)
  67. os.sleep(0.5)
  68. printCentered(4, "OS-SYSTEMS V1.12.2", colors.black, colors.cyan)
  69. printCentered(5, "------------------", colors.black, colors.gray)
  70.  
  71. local modules = {"Lade Kernel...", "Initialisiere Multishell...", "Pruefe Redstone-Verbindungen...", "Verbinde mit Project Red...", "System Bereit."}
  72.  
  73. for i, msg do
  74. printCentered(8, msg .. string.rep(" ", 15), colors.black, colors.white)
  75. drawProgressBar(10, i, #modules)
  76. os.sleep(0.6)
  77. end
  78. os.sleep(0.5)
  79. end
  80.  
  81. -- 2. PROFIL-ERSTELLUNG
  82. local function createProfileUI()
  83. clearScreen(colors.blue, colors.white)
  84.  
  85. if not sys_config.adminCreated then
  86. -- Admin Erstellung
  87. printCentered(3, "=== ERSTEINSCHALTUNG: ADMIN ERSTELLEN ===", colors.blue, colors.yellow)
  88.  
  89. term.setCursorPos(5, 7)
  90. term.write("Admin Name: ")
  91. local name = read()
  92.  
  93. term.setCursorPos(5, 9)
  94. term.write("Passwort: ")
  95. local pass = read("*") -- Versteckt die Eingabe
  96.  
  97. sys_config.adminName = name
  98. sys_config.adminPass = pass
  99. sys_config.adminCreated = true
  100. saveConfig()
  101.  
  102. printCentered(13, "Admin-Profil erfolgreich erstellt!", colors.blue, colors.lime)
  103. os.sleep(2)
  104. else
  105. -- Normaler User Erstellung (Optional aus dem Menü aufrufbar)
  106. clearScreen(colors.blue, colors.white)
  107. printCentered(3, "=== NEUEN NUTZER ANLEGEN ===", colors.blue, colors.yellow)
  108.  
  109. term.setCursorPos(5, 7)
  110. term.write("Username: ")
  111. local name = read()
  112.  
  113. term.setCursorPos(5, 9)
  114. term.write("Passwort: ")
  115. local pass = read("*")
  116.  
  117. sys_config.users[name] = pass
  118. saveConfig()
  119.  
  120. printCentered(13, "Nutzer erfolgreich angelegt!", colors.blue, colors.lime)
  121. os.sleep(2)
  122. end
  123. end
  124.  
  125. -- 3. LOGIN SCREEN
  126. local function loginUI()
  127. while true do
  128. clearScreen(colors.gray, colors.white)
  129. printCentered(3, "=== SYSTEM LOGIN ===", colors.gray, colors.cyan)
  130.  
  131. term.setCursorPos(5, 7)
  132. term.write("Benutzername: ")
  133. local user = read()
  134.  
  135. term.setCursorPos(5, 9)
  136. term.write("Passwort: ")
  137. local pass = read("*")
  138.  
  139. if user == sys_config.adminName and pass == sys_config.adminPass then
  140. return "admin"
  141. elseif sys_config.users[user] and sys_config.users[user] == pass then
  142. return "user"
  143. else
  144. printCentered(12, "Falsches Passwort oder Benutzer!", colors.gray, colors.red)
  145. os.sleep(2)
  146. end
  147. end
  148. end
  149.  
  150. -- 4. ADMIN & USER DASHBOARDS (Die Steuerung)
  151. local function updateRedstone()
  152. -- Gibt ein Redstone-Signal aus, wenn die Basissysteme aktiv sind
  153. redstone.setOutput(redstone_side, sys_config.systemsActive)
  154. end
  155.  
  156. local function adminDashboard()
  157. while true do
  158. clearScreen(colors.lightGray, colors.black)
  159. printCentered(2, "=== ADMIN DASHBOARD ===", colors.lightGray, colors.red)
  160.  
  161. -- Status-Anzeige
  162. local statusText = sys_config.systemsActive and "[ ONLINE ]" or "[ OFFLINE ]"
  163. local statusColor = sys_config.systemsActive and colors.green or colors.red
  164. printCentered(4, "Basis-Systeme: " .. statusText, colors.lightGray, statusColor)
  165.  
  166. -- Optionen
  167. term.setCursorPos(5, 7) term.write("1. Basissysteme Umschalten (An/Aus)")
  168. term.setCursorPos(5, 9) term.write("2. Neuen Standard-User anlegen")
  169. term.setCursorPos(5, 11) term.write("3. Abmelden")
  170.  
  171. printCentered(14, "Waehle eine Option (1-3): ", colors.lightGray, colors.black)
  172. local _, char = os.pullEvent("char")
  173.  
  174. if char == "1" then
  175. sys_config.systemsActive = not sys_config.systemsActive
  176. updateRedstone()
  177. saveConfig()
  178. elseif char == "2" then
  179. createProfileUI()
  180. elseif char == "3" then
  181. break
  182. end
  183. end
  184. end
  185.  
  186. local function userDashboard()
  187. while true do
  188. clearScreen(colors.lightGray, colors.black)
  189. printCentered(2, "=== USER DASHBOARD ===", colors.lightGray, colors.blue)
  190.  
  191. if not sys_config.systemsActive then
  192. printCentered(6, "!! AUF_ZUEGE SPERRT !!", colors.lightGray, colors.red)
  193. printCentered(8, "Die Basissysteme sind offline.", colors.lightGray, colors.black)
  194. printCentered(9, "Bitte den Admin, sie zu starten.", colors.lightGray, colors.black)
  195. else
  196. printCentered(6, "Aufzuege: BEREIT", colors.lightGray, colors.green)
  197. printCentered(8, "[Hier koennte deine Aufzugssteuerung stehen]", colors.lightGray, colors.gray)
  198. end
  199.  
  200. printCentered(13, "Druecke 'Q' zum Abmelden", colors.lightGray, colors.gray)
  201. local _, char = os.pullEvent("char")
  202. if char == "q" or char == "Q" then
  203. break
  204. end
  205. end
  206. end
  207.  
  208. -- HAUPTPROGRAMM-SCHLEIFE
  209. loadConfig()
  210. bootSequence()
  211.  
  212. if not sys_config.adminCreated then
  213. createProfileUI()
  214. end
  215.  
  216. -- Aktualisiere Redstone-Status direkt nach dem Boot (falls Server-Neustart)
  217. updateRedstone()
  218.  
  219. while true do
  220. local role = loginUI()
  221. if role == "admin" then
  222. adminDashboard()
  223. type = "user"
  224. userDashboard()
  225. end
  226. end
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment