Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Datei: start.lua
- -- Lädt die modabhängige Turbinensteuerung + GUI für CC: Tweaked mit effizientem Auto-Update
- -- Mod-Erkennung über Peripherie
- local function getModType()
- for _, name in ipairs(peripheral.getNames()) do
- local ptype = peripheral.getType(name)
- if ptype == "BigReactors-Turbine" then
- return "BigReactors"
- elseif ptype == "ExtremeReactors2-Turbine" then
- return "ExtremeReactors"
- elseif ptype == "BiggerReactors-Turbine" then
- return "BiggerReactors"
- end
- end
- term.setTextColor(colors.red)
- print("Kein unterstützter Reaktor-Mod gefunden!")
- print("Programm wird gestoppt und der CC-Computer in 15 Sekunden heruntergefahren")
- print("Bitte Fehler beheben und CC-Computer neustarten!")
- sleep(15)
- os.shutdown()
- end
- -- Pastebin-Links
- local pastebinLinks = {
- BigReactors = {
- turbine = "8xx3Ns3u" -- turbine_br.lua
- },
- ExtremeReactors = {
- turbine = "<PASTEBIN_KEY_ER>"
- },
- BiggerReactors = {
- turbine = "<PASTEBIN_KEY_BGR>"
- },
- common = {
- startup = "bHCyJny5",
- gui = "edBzYTzi",
- main = "dqaeHStp",
- config = "ZEx1hwKf",
- language = "Z48wKpjG",
- state = "UuMV4vQz",
- settingsmodel = "HqkrbCxb",
- userConfig = "crF6ViY5",
- }
- }
- -- Lädt Datei einmal herunter und gibt Inhalt zurück
- local function downloadToMemory(pasteKey, targetTmp)
- shell.run("pastebin get " .. pasteKey .. " " .. targetTmp)
- if not fs.exists(targetTmp) then
- error("Fehler beim Herunterladen von " .. pasteKey)
- end
- local f = fs.open(targetTmp, "r")
- local content = f.readAll() or ""
- f.close()
- return content
- end
- -- Datei ggf. aktualisieren (aber lädt Paste nur einmal)
- local function updateFileIfNeeded(pasteKey, filename)
- local dummy = {
- write = function() end,
- blit = function() end,
- clear = function() end,
- clearLine = function() end,
- getCursorPos = function() return 1, 1 end,
- setCursorPos = function() end,
- getSize = function() return 1, 1 end,
- getTextColour = function() end,
- setTextColour = function() end,
- setBackgroundColour = function() end,
- scroll = function() end,
- isColour = function() return true end
- }
- local contentUpdate = false
- local nativ = term.redirect(dummy)
- os.sleep(0.3)
- if filename == "userConfig" and fs.exists(filename) then
- term.redirect(nativ)
- term.setTextColor(colors.green)
- print("Datei \"" .. filename .. "\" ist vorhanden")
- else
- local tmpFile = ".tmp"
- if fs.exists(tmpFile) then fs.delete(tmpFile) end
- local newContent = downloadToMemory(pasteKey, tmpFile)
- local oldContent = ""
- if fs.exists(filename) then
- local f = fs.open(filename, "r")
- oldContent = f.readAll() or ""
- f.close()
- end
- if oldContent ~= newContent then
- contentUpdate = true
- if fs.exists(filename) then fs.delete(filename) end
- fs.copy(tmpFile, filename)
- end
- fs.delete(tmpFile)
- term.redirect(nativ)
- if contentUpdate == true then
- term.setTextColor(colors.yellow)
- print("Datei \"" .. filename .. "\" wird aktualisiert...")
- if filename == "startup" then
- print("\nStartup Datei wurde aktualisiert.\nStarte CC Computer in 5 Sekunden neu...")
- os.sleep(5)
- os.reboot()
- end
- else
- term.setTextColor(colors.green)
- print("Datei \"" .. filename .. "\" ist aktuell")
- end
- end
- term.setTextColor(colors.white)
- end
- -- Hauptlogik
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.red)
- print("Prüfe auf vorhandene Reaktor- oder Turbinenversion...\n")
- os.sleep(0.3)
- term.setTextColor(colors.purple)
- local modType = getModType()
- print("Mod erkannt: " .. modType .. "\n")
- local links = pastebinLinks[modType]
- os.sleep(0.5)
- if not links or not links.turbine then
- term.setTextColor(colors.red)
- print("Fehlender Pastebin-Link für den erkannten Modtyp: " .. (modType or "Unbekannt"))
- print("Bitte Startdatei erneut herunterladen")
- sleep(10)
- os.shutdown()
- end
- local common = pastebinLinks.common
- -- Gemeinsame Dateien prüfen und ggf. updaten
- updateFileIfNeeded(common.startup, "startup")
- updateFileIfNeeded(links.turbine, "turbine")
- updateFileIfNeeded(common.gui, "gui")
- updateFileIfNeeded(common.main, "orchestrator")
- updateFileIfNeeded(common.config, "config")
- updateFileIfNeeded(common.language, "language")
- updateFileIfNeeded(common.state, "state")
- updateFileIfNeeded(common.settingsmodel, "settingsmodel")
- updateFileIfNeeded(common.userConfig, "userConfig")
- -- Starte Programm
- term.setTextColor(colors.yellow)
- os.sleep(0.5)
- print("\nSteuerung wird gestartet...")
- sleep(3)
- shell.run("orchestrator")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement