Advertisement
PlatinKinggg

Funktionen-BiggerReactors

Jun 18th, 2023 (edited)
1,280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 56.30 KB | None | 0 0
  1. --[[
  2. Dies ist die erste Funktion, die bei Programmstart aufgeführt wird. Die darin aufgerufenen Funktionen initialisieren das Programm und alle notwendigen Variablen. Darüber hinaus werden alle Anzeigefenster erzeugt.
  3. ]]
  4.  
  5. function programInitialize()
  6.     systemStart()
  7.     configTable = config.load()
  8.     config.check()
  9.  
  10.     if debugLevel == 0 then
  11.         handler(globalVariables)
  12.     elseif debugLevel == 1 then
  13.         globalVariables()
  14.     end
  15.  
  16.     globalTables()
  17.     windowCreate.foundation()
  18.     windowCreate.interface()
  19.     windowCreate.aboutAutor()
  20.     windowCreate.optionMain()
  21.     windowCreate.pageMain()
  22.     windowCreate.pageRF()
  23.     windowCreate.pageFuel()
  24.     windowCreate.pageEfficiency()
  25.     windowCreate.optionSetting()
  26.     windowCreate.systemControl()
  27.     reactorAutostart()
  28. end
  29.  
  30.  
  31. --[[
  32. In dieser Funktion wird der optische Start des Programms durchgeführt. Anzeigen auf dem Terminal und dem angeschlossenen Monitor erscheinen. Zudem wird hier die initialisierung der Peripherie eingeleitet.
  33. ]]
  34.  
  35. function systemStart()
  36.     peripheralInitialize()
  37.     windowCreate.bootScreen()
  38.     monitor.clear()
  39.     display.bootScreen("PC fährt hoch...")
  40.     term.clear()
  41.     term.setTextColor(colors.white)
  42.     term.setCursorPos(1,1)
  43.     print("Reaktoranzeige Stavros V.: 1.1")
  44.     print("Powered by PlatinKinggg")
  45.     sleep(0.75)
  46.     term.setTextColor(colors.red)
  47.     print("Initialisiere")
  48.     sleep(1)
  49.     term.setTextColor(colors.white)
  50.     print(".")
  51.     sleep(0.5)
  52.     print("..")
  53.     sleep(0.5)
  54.     print("...")
  55.     sleep(0.5)
  56.     term.setTextColor(colors.red)
  57.     print("Suche nach Programmkonflikten startet jetzt")
  58.     term.setTextColor(colors.green)
  59.     print("Keine Initialisierungsfehler detektiert")
  60.     print("Beginne mit Anzeige")
  61.     sleep(0.5)
  62.     term.clear()
  63.     term.setTextColor(colors.white)
  64.     term.setCursorPos(1,1)
  65.     print("Reaktoranzeige Stavros V.: 1.1")
  66.     print("Powered by PlatinKinggg")
  67.     term.setTextColor(colors.red)
  68.     print(" ")
  69.     print("Drücke Entf um das System neuzustarten")
  70.     term.setTextColor(colors.white)
  71. end
  72.  
  73.  
  74. --[[
  75. In dieser Funktion werden die Peripheriegeräte Reaktor, Monitor und Alaram hier initialisiert und mit einem Wrap versehen.
  76. ]]
  77.  
  78. function peripheralInitialize()
  79.     for key, value in pairs(peripheral.getNames()) do
  80.         if peripheral.getType(value) == "BiggerReactors_Reactor" then
  81.             reactor = peripheral.wrap(value)
  82.         elseif peripheral.getType(value) == "monitor" then
  83.             monitor = peripheral.wrap(value)
  84.         elseif peripheral.getType(value) == "industrialAlarm" then
  85.             alarm = peripheral.wrap(value)
  86.         end
  87.     end
  88.     sleep(1)
  89.     if reactor == nil then
  90.         print("An das Netzwerk ist kein Reaktor angeschlossen")
  91.         print("Programm wird gestoppt und der CC-Computer in 10 Sekunden neugestartet")
  92.         sleep(10)
  93.         os.reboot()
  94.     elseif monitor == nil then
  95.         print("An das Netzwerk ist kein Monitor angeschlossen")
  96.         print("Programm wird gestoppt und der CC-Computer in 5 Minuten neugestartet")
  97.         sleep(300)
  98.         os.reboot()
  99.     end
  100.     monitorCheck()
  101.     monitor.setBackgroundColor(colors.black)
  102.     monitor.clear()
  103. end
  104.  
  105. function monitorCheck()
  106.     monitorWidth, monitorHeight = monitor.getSize()
  107.     if monitorWidth < 39 then
  108.         print("Bildschirm nicht Breit genug! Bitte den Monitor auf 4 Blöcke Breite erweitern")
  109.         sleep(1)
  110.         print("Programm wird gestoppt und der CC-Computer in 10 Sekunden neugestartet")
  111.         sleep(10)
  112.         os.reboot()
  113.     elseif monitorHeight < 19 then
  114.         print("Bildschirm nicht Hoch genug! Bitte den Monitor auf 3 Blöcke Breite erweitern")
  115.         sleep(1)
  116.         print("Programm wird gestoppt und der CC-Computer in 10 Sekunden neugestartet")
  117.         sleep(10)
  118.         os.reboot()
  119.     end
  120. end
  121.  
  122. function globalVariables()
  123.     configTableText = {}
  124.     configTableInfo = {}
  125.  
  126.     configTableInfo[1] = "Auswahl Programmsprache:"
  127.     configTableText[1] = {"Deutsch", "Englisch"}
  128.     if configTable[1] == 1 then
  129.         --WIP: Table language <- Table Deutsch
  130.     elseif configTable[1] == 2 then
  131.         --WIP: Table language <- Table Englisch
  132.     end
  133.  
  134.     configTableInfo[2] = "Reaktor startet bei Programmstart:"
  135.     configTableText[2] = {"Aktiv", "Kein Autostart"}
  136.     if configTable[2] == 1 then
  137.         autostart = true
  138.     else
  139.         autostart = false
  140.     end
  141.  
  142.     configTableInfo[3] = "Format Uhrzeitanzeige:"
  143.     configTableText[3] = {"24 Stunden Anzeige ohne Uhr Suffix", "24 Stunden Anzeige mit Uhr Suffix", "AM/PM Zeit mit AM/PM Suffix", "AM/PM Zeit ohne AM/PM Suffix"}
  144.     if configTable[3] == 1 then
  145.         dayTime = os.date("%R")         -- 24 Stunden Anzeige ohne "Uhr" Suffix
  146.     elseif configTable[3] == 2 then
  147.         dayTime = os.date("%R Uhr")     -- 24 Stunden Anzeige mit "Uhr" Suffix
  148.     elseif configTable[3] == 3 then
  149.         dayTime = os.date("%I:%M")      -- AM/PM Zeit ohne "AM/PM" Suffix
  150.     elseif configTable[3] == 4 then
  151.         dayTime = os.date("%I:%M %p")   -- AM/PM Zeit mit "AM/PM" Suffix
  152.     end
  153.  
  154.     configTableInfo[4] = "Format Datumsanzeige:"
  155.     configTableText[4] = {"Datumsangabe Deutsch", "Datumsangabe Englisch I", "Datumsangabe Englisch II", "Datumsangabe Europäisch"}
  156.     if configTable[4] == 1 then
  157.         dateTime = os.date("%d.%m.%Y")  -- Datumsangabe Deutsch
  158.     elseif configTable[4] == 2 then
  159.         dateTime = os.date("%d/%m/%Y")  -- Datumsangabe Englisch I
  160.     elseif configTable[4] == 3 then
  161.         dateTime = os.date("%m/%d/%Y")  -- Datumsangabe Englisch II
  162.     elseif configTable[4] == 4 then
  163.         dateTime = os.date("%Y/%m/%d")  -- Datumsangabe Europäisch
  164.     end
  165.  
  166.     configTableInfo[5] = "Startseite bei Programmstart:"
  167.     configTableText[5] = {"Übersicht", "Energieproduktion", "Brennstoff-Info", "Brennstoff-Effizienz"}
  168.     if page == nil then
  169.         if configTable[5] == 1 then
  170.             page = 1
  171.             pageHeader = "Übersicht"
  172.         elseif configTable[5] == 2 then
  173.             page = 2
  174.             pageHeader = "Energieproduktion"
  175.         elseif configTable[5] == 3 then
  176.             page = 3
  177.             pageHeader = "Brennstoff-Info"                 
  178.         elseif configTable[5] == 4 then
  179.             page = 4
  180.             pageHeader = "Brennstoff-Effizienz"                
  181.         end
  182.     end
  183.  
  184.     for i = 6, 12, 1 do
  185.         local variableName
  186.         if configTable[i] == 1 then
  187.             variableName = colors.white
  188.         elseif configTable[i] == 2 then
  189.             variableName = colors.orange
  190.         elseif configTable[i] == 3 then
  191.             variableName = colors.magenta
  192.         elseif configTable[i] == 4 then
  193.             variableName = colors.lightBlue
  194.         elseif configTable[i] == 5 then
  195.             variableName = colors.yellow
  196.         elseif configTable[i] == 6 then
  197.             variableName = colors.lime
  198.         elseif configTable[i] == 7 then
  199.             variableName = colors.pink
  200.         elseif configTable[i] == 8 then
  201.             variableName = colors.gray
  202.         elseif configTable[i] == 9 then
  203.             variableName = colors.lightGray
  204.         elseif configTable[i] == 10 then
  205.             variableName = colors.cyan
  206.         elseif configTable[i] == 11 then
  207.             variableName = colors.purple
  208.         elseif configTable[i] == 12 then
  209.             variableName = colors.blue
  210.         elseif configTable[i] == 13 then
  211.             variableName = colors.brown
  212.         elseif configTable[i] == 14 then
  213.             variableName = colors.green
  214.         elseif configTable[i] == 15 then
  215.             variableName = colors.red
  216.         elseif configTable[i] == 16 then
  217.             variableName = colors.black
  218.         end
  219.         if i == 6 then
  220.             configTableInfo[i] = "Hintergrundfarbe Tastenleiste:"
  221.             configTableText[i] = {"Weiß", "Orange", "Magenta", "Hellblau", "Gelb", "Limette", "Pink", "Grau", "HellGrau", "Cyan", "Lila", "Blau", "Braun", "Grün", "Rot", "Schwarz"}
  222.             backgroundWindowBackgroundColor = variableName
  223.         elseif i == 7 then
  224.             configTableInfo[i] = "Hintergrundfarbe der Tasten:"
  225.             configTableText[i] = {"Weiß", "Orange", "Magenta", "Hellblau", "Gelb", "Limette", "Pink", "Grau", "HellGrau", "Cyan", "Lila", "Blau", "Braun", "Grün", "Rot", "Schwarz"}
  226.             buttonWindowBackgroundColor = variableName
  227.         elseif i == 8 then
  228.             configTableInfo[i] = "Schriftfarbe der Tasten:"
  229.             configTableText[i] = {"Weiß", "Orange", "Magenta", "Hellblau", "Gelb", "Limette", "Pink", "Grau", "HellGrau", "Cyan", "Lila", "Blau", "Braun", "Grün", "Rot", "Schwarz"}
  230.             buttonWindowTextColor = variableName
  231.         elseif i == 9 then
  232.             configTableInfo[i] = "Hintergrundfarbe der Header/Datum Anzeige:"
  233.             configTableText[i] = {"Weiß", "Orange", "Magenta", "Hellblau", "Gelb", "Limette", "Pink", "Grau", "HellGrau", "Cyan", "Lila", "Blau", "Braun", "Grün", "Rot", "Schwarz"}
  234.             textWindowBackgroundColor = variableName
  235.         elseif i == 10 then
  236.             configTableInfo[i] = "Schriftfarbe der Header/Datum Anzeige:"
  237.             configTableText[i] = {"Weiß", "Orange", "Magenta", "Hellblau", "Gelb", "Limette", "Pink", "Grau", "HellGrau", "Cyan", "Lila", "Blau", "Braun", "Grün", "Rot", "Schwarz"}
  238.             textWindowTextColor = variableName
  239.         elseif i == 11 then
  240.             configTableInfo[i] = "Hintergrundfarbe der Seite Übersicht:"
  241.             configTableText[i] = {"Weiß", "Orange", "Magenta", "Hellblau", "Gelb", "Limette", "Pink", "Grau", "HellGrau", "Cyan", "Lila", "Blau", "Braun", "Grün", "Rot", "Schwarz"}
  242.             paigeMainBackgroundColor = variableName
  243.         elseif i == 12 then
  244.             configTableInfo[i] = "Schriftfarbe der Seite Übersicht:"
  245.             configTableText[i] = {"Weiß", "Orange", "Magenta", "Hellblau", "Gelb", "Limette", "Pink", "Grau", "HellGrau", "Cyan", "Lila", "Blau", "Braun", "Grün", "Rot", "Schwarz"}
  246.             paigeMainTextColor  = variableName
  247.         end
  248.     end
  249.  
  250.     if fuelburnedLastTick == nil then
  251.         fuelburnedLastTick = {}
  252.     end
  253.  
  254.     fuelburnedLastTickRaw = reactor.fuelTank().burnedLastTick()
  255.  
  256.     if fuelburnedLastTickRaw < 1 then
  257.         fuelburnedLastTick[1] = string.format("%.3f", reactor.fuelTank().burnedLastTick())
  258.         fuelburnedLastTick[2] = " mB/Tick"
  259.     elseif fuelburnedLastTickRaw < 1000 then
  260.         fuelburnedLastTick[1] = string.format("%.1f", reactor.fuelTank().burnedLastTick())
  261.         fuelburnedLastTick[2] = " mB/Tick"
  262.     elseif fuelburnedLastTickRaw < 1000000 then
  263.         fuelburnedLastTick[1] = string.format("%.32f", (reactor.fuelTank().burnedLastTick() / 1000))
  264.         fuelburnedLastTick[2] = " B/Tick"
  265.     end
  266.  
  267.     if fuelAmount == nil then
  268.         fuelAmount = {}
  269.     end
  270.  
  271.     fuelAmountRaw = reactor.fuelTank().fuel()
  272.     if fuelAmountRaw < 1000 then
  273.         fuelAmount[1] = math.ceil(reactor.fuelTank().fuel())
  274.         fuelAmount[2] = " mB"
  275.     elseif fuelAmountRaw < 1000000 then
  276.         fuelAmount[1] = math.ceil(reactor.fuelTank().fuel() / 1000)
  277.         fuelAmount[2] = " B"
  278.     elseif fuelAmountRaw < 1000000000 then
  279.         fuelAmount[1] = math.ceil(reactor.fuelTank().fuel() / 1000000)
  280.         fuelAmount[2] = " KB"
  281.     end
  282.  
  283.     fuelTankCapacity = reactor.fuelTank().capacity()
  284.     fuelAmountPercent = math.ceil((fuelAmountRaw / fuelTankCapacity) * 100)
  285.     fuelTotalReactant = reactor.fuelTank().totalReactant()
  286.     ejectWaste = reactor.fuelTank().ejectWaste
  287.     fuelTankWaste = reactor.fuelTank().waste()
  288.     fuelReactivity = reactor.fuelTank().fuelReactivity()
  289.     reactorActive = reactor.active()
  290.     ambietTemperature = reactor.ambientTemperature()
  291.     connected = reactor.connected()
  292.     setAllControlRodLevels = reactor.setAllControlRodLevels
  293.     stackTemperature = reactor.stackTemperature()
  294.     apiVersion = reactor.apiVersion
  295.     setActive = reactor.setActive
  296.     casingTemperature = reactor.casingTemperature()
  297.     fuelTemperature = math.ceil(reactor.fuelTemperature())
  298.     controlRodCount = reactor.controlRodCount()
  299.     getControlRodLevel = reactor.getControlRod(0).level()
  300.  
  301.     if type(reactor.battery()) == "table" then
  302.         activeCooling = false
  303.  
  304.         if storedRF == nil then
  305.             storedRF = {}
  306.         end
  307.  
  308.         storedRFRaw = reactor.battery().stored()
  309.         if storedRFRaw >= 1000000000 then
  310.             storedRF[1] = math.floor(storedRFRaw / 1000000000)
  311.             storedRF[2] = " gRF"
  312.         elseif storedRFRaw >= 1000000 then
  313.             storedRF[1] = math.floor(storedRFRaw / 1000000)
  314.             storedRF[2] = " mRF"
  315.         elseif storedRFRaw >= 1000 then
  316.             storedRF[1] = math.floor(storedRFRaw / 1000)
  317.             storedRF[2] = " kRF"
  318.         elseif storedRFRaw > 0 then
  319.             storedRF[1] = math.floor(storedRFRaw)
  320.             storedRF[2] = " RF"
  321.         else
  322.             storedRF[1] = 0
  323.             storedRF[2] = " RF"
  324.         end
  325.  
  326.         capacityRFRaw = reactor.battery().capacity()
  327.         if capacityRF == nil then
  328.             capacityRF = {}
  329.         end
  330.         if capacityRFRaw >= 1000000000 then
  331.             capacityRF[1] = math.floor(capacityRFRaw / 1000000000)
  332.             capacityRF[2] = " GRF"
  333.         elseif capacityRFRaw >= 1000000 then
  334.             capacityRF[1] = math.floor(capacityRFRaw / 1000000)
  335.             capacityRF[2] = " MRF"
  336.         elseif capacityRFRaw >= 1000 then
  337.             capacityRF[1] = math.floor(capacityRFRaw / 1000)
  338.             capacityRF[2] = " KRF"
  339.         elseif capacityRFRaw > 0 then
  340.             capacityRF[1] = math.floor(capacityRFRaw)
  341.             capacityRF[2] = " RF"
  342.         else
  343.             capacityRF[1] = 0
  344.             capacityRF[2] = " RF"
  345.         end
  346.  
  347.         producedRFLastTickRaw = reactor.battery().producedLastTick()
  348.  
  349.         if producedRFLastTick == nil then
  350.             producedRFLastTick = {}
  351.         end
  352.  
  353.         if producedRFLastTickRaw >= 1000000000 then
  354.             producedRFLastTick[1] = math.floor(producedRFLastTickRaw / 1000000000)
  355.             producedRFLastTick[2] = " GRF/Tick"
  356.         elseif producedRFLastTickRaw >= 1000000 then
  357.             producedRFLastTick[1] = math.floor(producedRFLastTickRaw / 1000000)
  358.             producedRFLastTick[2] = " MRF/Tick"
  359.         elseif producedRFLastTickRaw >= 1000 then
  360.             producedRFLastTick[1] = math.floor(producedRFLastTickRaw / 1000)
  361.             producedRFLastTick[2] = " KRF/Tick"
  362.         elseif producedRFLastTickRaw > 0 then
  363.             producedRFLastTick[1] = math.floor(producedRFLastTickRaw)
  364.             producedRFLastTick[2] = " RF/Tick"
  365.         else
  366.             producedRFLastTick[1] = 0
  367.             producedRFLastTick[2] = " RF/Tick"
  368.         end
  369.  
  370.         passivEfficiencyRaw = math.floor((producedRFLastTickRaw / fuelburnedLastTickRaw))
  371.  
  372.         if passivEfficiency == nil then
  373.             passivEfficiency = {}
  374.         end
  375.  
  376.         if passivEfficiencyRaw >= 1000000 then
  377.             passivEfficiency[1] = math.floor(passivEfficiencyRaw / 1000000)
  378.             passivEfficiency[2] = " MRF/Tick/mB"
  379.         elseif passivEfficiencyRaw >= 1000 then
  380.             passivEfficiency[1] = math.floor(passivEfficiencyRaw / 1000)
  381.             passivEfficiency[2] = " KRF/Tick/mB"
  382.         elseif passivEfficiencyRaw > 0 then
  383.             passivEfficiency[1] = math.floor(passivEfficiencyRaw)
  384.             passivEfficiency[2] = " RF/Tick/mB"
  385.         else
  386.             passivEfficiency[1] = 0
  387.             passivEfficiency[2] = " RF/Tick/mB"
  388.         end
  389.     else
  390.         activeCooling = true
  391.         coolantTankMaxTransitionedLastTick = reactor.coolantTank().maxTransitionedLastTick()
  392.         coolantTankTransitionedLastTick = reactor.coolantTank().transitionedLastTick()
  393.         coolantTankCapacity = reactor.coolantTank().capacity()
  394.         HotFluidAmount = reactor.coolantTank().hotFluidAmount()
  395.         ColdFluidAmount = reactor.coolantTank().coldFluidAmount()
  396.         coolantTankDump = reactor.coolantTank().dump
  397.  
  398.         activEfficiency = math.floor(coolantTankTransitionedLastTick / R.fuelburnedLastTick)
  399.     end
  400.  
  401.     if controlRodSteeringTimer == nil then
  402.         controlRodSteeringTimer = 0
  403.     end
  404.  
  405.     if storedRFOld == nil then
  406.         storedRFOld = 0
  407.     end
  408.  
  409.     if fuelTemperatureOld == nil then
  410.         fuelTemperatureOld = 0
  411.     end
  412.  
  413.     fuelTemperatureSweetSpot = 1273
  414.  
  415.     if currentOptionPage == nil then
  416.         currentOptionPage = 1
  417.     end
  418.  
  419. --[[
  420. Mit diesem Abschnitt wird die RF Produktion der letzten 5 Minuten aufgezeichnet. Hierzu wird eine Table angelegt und jede Sekunde die aktuelle Energieproduktion darin hinterlegt und zusammengerechnet.
  421. ]]
  422.  
  423.     if rfProducedHistory == nil then
  424.         rfProducedHistory = {producedRFLastTickRaw * 20}
  425.     end
  426.    
  427.     if table.getn(rfProducedHistory) < 300 then
  428.         table.insert(rfProducedHistory, (producedRFLastTickRaw * 20))
  429.     else
  430.         table.remove(rfProducedHistory, 1)
  431.         table.insert(rfProducedHistory, (producedRFLastTickRaw * 20))
  432.     end
  433.    
  434.     rfProducedHistoryTotal = 0
  435.  
  436.     for key, value in ipairs(rfProducedHistory) do
  437.         rfProducedHistoryTotal = rfProducedHistoryTotal + value
  438.     end
  439.  
  440.     if rfProducedHistorySum == nil then
  441.         rfProducedHistorySum = {}
  442.     end
  443.  
  444.     if rfProducedHistoryTotal >= 1000000000 then
  445.         rfProducedHistorySum[1] = string.format("%.2f", rfProducedHistoryTotal / 1000000000)
  446.         rfProducedHistorySum[2] = " GRF"
  447.     elseif rfProducedHistoryTotal >= 1000000 then
  448.         rfProducedHistorySum[1] = string.format("%.2f", rfProducedHistoryTotal/ 1000000)
  449.         rfProducedHistorySum[2] = " MRF"
  450.     elseif rfProducedHistoryTotal >= 1000 then
  451.         rfProducedHistorySum[1] = string.format("%.2f", rfProducedHistoryTotal/ 1000)
  452.         rfProducedHistorySum[2] = " KRF"
  453.     elseif rfProducedHistoryTotal > 0 then
  454.         rfProducedHistorySum[1] = string.format("%.2f", rfProducedHistoryTotal)
  455.         rfProducedHistorySum[2] = " RF"
  456.     else
  457.         rfProducedHistorySum[1] = 0
  458.         rfProducedHistorySum[2] = " RF"
  459.     end
  460.  
  461.  
  462. --[[
  463. Mit diesem Abschnitt wird der Brennstoffverbrauch der letzten 5 Minuten aufgezeichnet. Hierzu wird eine Table angelegt und jede Sekunde die aktuellen Verbrauchswerte darin hinterlegt und zusammengerechnet.
  464. ]]
  465.     fuelburnedLastTickOld= fuelburnedLastTickRaw
  466.     if fuelBurnedHistory == nil then
  467.         fuelBurnedHistory = {fuelburnedLastTickRaw}
  468.     end
  469.  
  470.     if table.getn(fuelBurnedHistory) < 300 then
  471.         table.insert(fuelBurnedHistory, (fuelburnedLastTickRaw * 20))
  472.     else
  473.         table.remove(fuelBurnedHistory, 1)
  474.         table.insert(fuelBurnedHistory, (fuelburnedLastTickRaw * 20))
  475.     end
  476.  
  477.     fuelBurnedHistoryTotal = 0
  478.     for key, value in ipairs(fuelBurnedHistory) do
  479.         fuelBurnedHistoryTotal = fuelBurnedHistoryTotal + value
  480.     end
  481.  
  482.     if fuelBurnedHistorySum == nil then
  483.         fuelBurnedHistorySum = {}
  484.     end
  485.  
  486.     if fuelBurnedHistoryTotal < 1 then
  487.         fuelBurnedHistorySum[1] = string.format("%.3f", fuelBurnedHistoryTotal)
  488.         fuelBurnedHistorySum[2] = " mB"
  489.     elseif fuelBurnedHistoryTotal < 1000 then
  490.         fuelBurnedHistorySum[1] = string.format("%.1f", fuelBurnedHistoryTotal)
  491.         fuelBurnedHistorySum[2] = " mB"
  492.     elseif fuelBurnedHistoryTotal < 1000000 then
  493.         fuelBurnedHistorySum[1] = string.format("%.2f", (fuelBurnedHistoryTotal / 1000))
  494.         fuelBurnedHistorySum[2] = " B"
  495.     else
  496.         fuelBurnedHistorySum[1] = string.format("%.3f", (fuelBurnedHistoryTotal / 1000000))
  497.         fuelBurnedHistorySum[2] = " KB"
  498.     end
  499. end
  500.  
  501.  
  502. --[[
  503. In dieser Funktion werden die globalen Tables für verschiedene Zwecke initialisiert. Da die Werte in den Tables statisch sind, ist diese Funktion gesondert definiert und nicht in der globalVariables-Funktion eingebettet.
  504. ]]
  505.  
  506. function globalTables()
  507.     --SystemControlText[currentSettingsPage][settingsWindow][text]
  508.     SystemControlText = { { {}, {}, {}, {} }, { {}, {}, {}, {} }, { {}, {}, {}, {} } }
  509.  
  510.  
  511.     SystemControlText[1][1][1] = "Über den Autor"
  512.     SystemControlText[1][1][2] = "dieses Programms"
  513.  
  514.     SystemControlText[1][2][1] = "test"
  515.     SystemControlText[1][2][2] = "test"
  516.  
  517.     SystemControlText[1][3][1] = "test"
  518.     SystemControlText[1][3][2] = "test"
  519.  
  520.     SystemControlText[1][4][1] = "test"
  521.     SystemControlText[1][4][2] = "test"
  522.  
  523.  
  524.     SystemControlText[2][1][1] = "Reaktor"
  525.     SystemControlText[2][1][2] = "Runterfahren"
  526.     SystemControlText[2][1][3] = "Hochfahren"
  527.  
  528.     SystemControlText[2][2][1] = "Steuerstäbe"
  529.     SystemControlText[2][2][2] = "Zurücksetzen"
  530.  
  531.     SystemControlText[2][3][1] = "Manuelle"
  532.     SystemControlText[2][3][2] = "Abfallentleerung"
  533.  
  534.     SystemControlText[2][4][1] = "Reaktorsteuerung"
  535.     SystemControlText[2][4][2] = "Neustarten"
  536.  
  537.  
  538.     aboutAutorText = {}
  539.  
  540.     aboutAutorText[1] = "Über das Programm: Stavros - Reaktosteuerung"
  541.     aboutAutorText[2] = " "
  542.     aboutAutorText[3] = "Vielen Dank für die Nutzung meines Programms :)"
  543.     aboutAutorText[4] = "Mein Name ist Domenic Halking aka PlatinKinggg und"
  544.     aboutAutorText[5] = "die Reaktorsteuerung über ein selbstgeschriebenes"
  545.     aboutAutorText[6] = "Programm, hat mich schon seit Jahren interessiert."
  546.     aboutAutorText[7] = "Deshalb habe ich mit dem Programmieren angefangen."
  547.     aboutAutorText[8] = "Ich hoffe, das Ergebnis hier stellt Dich"
  548.     aboutAutorText[9] = "zufrieden und hilft Dir, deinen Reaktor gut im"
  549.     aboutAutorText[10] = "Auge zu behalten."
  550.     aboutAutorText[11] = "Falls dir das Programm gefällt, würde ich mich"
  551.     aboutAutorText[12] = "über ein Spende per PayPal freuen. Vielen Dank"
  552.     aboutAutorText[13] = " "
  553.     aboutAutorText[14] = "https://paypal.me/DHalking"
  554.  
  555. end
  556.  
  557. function alarmTrigger()
  558.     if fuelAmountRaw < (fuelTankCapacity / 4) then
  559.         rs.setOutput("top", true)
  560.     else
  561.         rs.setOutput("top", false)
  562.     end
  563. end
  564.  
  565. function controlRodSteering()
  566.  
  567.     controlMethod = 2
  568.  
  569.     if controlMethod == 1 then
  570.  
  571.         if storedRFRaw <= (capacityRFRaw * 0.01) then
  572.             setAllControlRodLevels(getControlRodLevel - 25)
  573.  
  574.         elseif storedRFRaw >= (capacityRFRaw * 0.99) then
  575.             setAllControlRodLevels(getControlRodLevel + 25)
  576.  
  577.         elseif storedRFRaw > storedRFOld then
  578.  
  579.             if storedRFRaw >= (capacityRFRaw * 0.90) then
  580.                 setAllControlRodLevels(getControlRodLevel + 9)
  581.  
  582.             elseif storedRFRaw >= (capacityRFRaw * 0.80) then
  583.                 setAllControlRodLevels(getControlRodLevel + 7)
  584.  
  585.             elseif storedRFRaw >= (capacityRFRaw * 0.7) then
  586.                 setAllControlRodLevels(getControlRodLevel + 5)
  587.  
  588.             elseif storedRFRaw >= (capacityRFRaw * 0.6) or storedRFRaw >= (storedRFOld * 1.03) then
  589.                 setAllControlRodLevels(getControlRodLevel + 3)
  590.  
  591.             else
  592.                 setAllControlRodLevels(getControlRodLevel + 1)
  593.             end
  594.  
  595.         elseif storedRFRaw < storedRFOld then
  596.  
  597.             if storedRFRaw <= (capacityRFRaw * 0.1) then
  598.                 setAllControlRodLevels(getControlRodLevel - 9)
  599.  
  600.             elseif storedRFRaw <= (capacityRFRaw * 0.2) then
  601.                 setAllControlRodLevels(getControlRodLevel - 7)  
  602.  
  603.             elseif storedRFRaw <= (capacityRFRaw * 0.3) then
  604.                 setAllControlRodLevels(getControlRodLevel - 5)  
  605.  
  606.             elseif storedRFRaw <= (capacityRFRaw * 0.4) or storedRFRaw <= (storedRFOld * 0.97) then
  607.                 setAllControlRodLevels(getControlRodLevel - 3)  
  608.  
  609.             else
  610.                 setAllControlRodLevels(getControlRodLevel - 1)
  611.             end
  612.         end
  613.  
  614.     elseif controlMethod == 2 then
  615.  
  616.         if fuelTemperature > 2000 then
  617.             setAllControlRodLevels(getControlRodLevel + 9)
  618.  
  619.         elseif fuelTemperature > (fuelTemperatureSweetSpot * 1.4) then
  620.             setAllControlRodLevels(getControlRodLevel + 7)
  621.  
  622.         elseif fuelTemperature > (fuelTemperatureSweetSpot * 1.3) then
  623.             setAllControlRodLevels(getControlRodLevel + 5)
  624.  
  625.         elseif fuelTemperature > (fuelTemperatureSweetSpot * 1.2) then
  626.             setAllControlRodLevels(getControlRodLevel + 3)
  627.  
  628.         elseif fuelTemperature > fuelTemperatureSweetSpot then
  629.             setAllControlRodLevels(getControlRodLevel + 1)
  630.  
  631.         elseif fuelTemperature < (fuelTemperatureSweetSpot * 0.2) then
  632.             setAllControlRodLevels(getControlRodLevel - 9)
  633.  
  634.         elseif fuelTemperature < (fuelTemperatureSweetSpot * 0.4) then
  635.             setAllControlRodLevels(getControlRodLevel - 7)
  636.  
  637.         elseif fuelTemperature < (fuelTemperatureSweetSpot * 0.6) then
  638.             setAllControlRodLevels(getControlRodLevel - 5)
  639.  
  640.         elseif fuelTemperature < (fuelTemperatureSweetSpot * 0.8) then
  641.             setAllControlRodLevels(getControlRodLevel - 3)
  642.  
  643.         elseif fuelTemperature < fuelTemperatureSweetSpot then
  644.             setAllControlRodLevels(getControlRodLevel - 1)
  645.  
  646.         end
  647.     end
  648.  
  649.     fuelTemperatureOld = fuelTemperature
  650.     storedRFOld = storedRFRaw
  651.     controlRodSteeringTimer = 0    
  652. end
  653.  
  654. function deleteProgram()
  655.     fs.delete("startUp")
  656.     fs.delete("Reaktoranzeige")
  657.     fs.delete("Programmkonfiguration")
  658.     fs.delete("ReadMeVariables")
  659. end
  660.  
  661. config = {
  662.     save = (function()
  663.         local configFile = io.open("Programmkonfiguration", "w")
  664.         configFile:write(textutils.serialise(configTable))
  665.         configFile:close()
  666.     end),
  667.  
  668.     load = (function()
  669.         if fs.exists("Programmkonfiguration") == false then
  670.             print(" ")
  671.             term.setTextColor(colors.yellow)
  672.             print("Keine Programmkonfigurations-Datei gefunden. Lege Datei nun an.")
  673.             term.setTextColor(colors.white)
  674.             print(" ")
  675.             configTable = config.restore()
  676.         end
  677.         local configFile = io.open("Programmkonfiguration", "r")
  678.         local configSerialse = configFile:read("a")
  679.         configFile:close()
  680.         configTable = textutils.unserialise(configSerialse)
  681.         return configTable
  682.     end),
  683.  
  684.     check = (function()
  685.         if type(configTable) ~= "table" then
  686.             configTable = config.restore()
  687.         else
  688.             local configTableLength = 0
  689.             for _ in pairs(configTable) do
  690.                 configTableLength = configTableLength + 1
  691.             end
  692.             if configTableLength ~= 12 then
  693.                 term.setTextColor(colors.red)
  694.                 print("Fehler in der Länge der Programmkonfiguration...")
  695.                 term.setTextColor(colors.white)
  696.                 configTable = config.restore()
  697.             elseif configTable[1] < 1 or configTable[1] > 2 then    -- Sprache
  698.                 term.setTextColor(colors.red)
  699.                 print("Fehler in der Zeitanzeige Einstellung...")
  700.                 term.setTextColor(colors.white)
  701.                 configTable = config.restore()
  702.             elseif configTable[2] < 1 or configTable[2] > 2 then    -- Auto-Einschalten
  703.                 term.setTextColor(colors.red)
  704.                 print("Fehler in der Zeitanzeige Einstellung...")
  705.                 term.setTextColor(colors.white)
  706.                 configTable = config.restore()
  707.             elseif configTable[3] < 1 or configTable[3] > 4 then    -- Uhrzeit
  708.                 term.setTextColor(colors.red)
  709.                 print("Fehler in der Zeitanzeige Einstellung...")
  710.                 term.setTextColor(colors.white)
  711.                 configTable = config.restore()
  712.             elseif configTable[4] < 1 or configTable[4] > 4 then    -- Datum
  713.                 term.setTextColor(colors.red)
  714.                 print("Fehler in der Datumsanzeige Einstellung...")
  715.                 term.setTextColor(colors.white)
  716.                 configTable = config.restore()
  717.             elseif configTable[5] < 1 or configTable[5] > 5 then    -- Startseite
  718.                 term.setTextColor(colors.red)
  719.                 print("Fehler in der Startseiten Einstellung")
  720.                 term.setTextColor(colors.white)
  721.                 configTable = config.restore()
  722.             elseif configTable[6] < 1 or configTable[6] > 16 then   -- StartseiteHintergrundfarbe buttonWindows
  723.                 term.setTextColor(colors.red)
  724.                 print("Fehler in der Einstellung zur Tasten-Hintergrundfarbe...")
  725.                 term.setTextColor(colors.white)
  726.                 configTable = config.restore()
  727.             elseif configTable[7] < 1 or configTable[7] > 16 then   -- Schriftfarbe buttonWindows
  728.                 term.setTextColor(colors.red)
  729.                 print("Fehler in der Einstellung zur Tasten-Schriftfarbe...")
  730.                 term.setTextColor(colors.white)
  731.                 configTable = config.restore()
  732.             elseif configTable[8] < 1 or configTable[8] > 16 then   -- Hintergrundfarbe textWindows
  733.                 term.setTextColor(colors.red)
  734.                 print("Fehler in der Einstellung zur Textanzeige-Hintergrundfarbe...")
  735.                 term.setTextColor(colors.white)
  736.                 configTable = config.restore()
  737.             elseif configTable[9] < 1 or configTable[9] > 16 then   -- Schriftfarbe textWindows
  738.                 term.setTextColor(colors.red)
  739.                 print("Fehler in der Einstellung zur Textanzeige-Schriftfarbe...")
  740.                 term.setTextColor(colors.white)
  741.                 configTable = config.restore()
  742.             elseif configTable[10] < 1 or configTable[10] > 16 then -- Hintergrundfarbe buttonWindowBackgroundColor
  743.                 term.setTextColor(colors.red)
  744.                 print("Fehler in der Hintergrundfarbe der Tastenleiste...")
  745.                 term.setTextColor(colors.white)
  746.                 configTable = config.restore()
  747.             elseif configTable[11] < 1 or configTable[11] > 16 then -- Hintergrundfarbe Übersicht
  748.                 term.setTextColor(colors.red)
  749.                 print("Fehler in der Hintergrundfarbe der Seite Übersicht...")
  750.                 term.setTextColor(colors.white)
  751.                 configTable = config.restore()
  752.             elseif configTable[12] < 1 or configTable[12] > 16 then -- Schriftfarbe Übersicht
  753.                 term.setTextColor(colors.red)
  754.                 print("Fehler in der Schriftfarbe der Seite Übersicht...")
  755.                 term.setTextColor(colors.white)
  756.                 configTable = config.restore()
  757.             end
  758.         end
  759.     end),
  760.  
  761.     restore = (function()
  762.         configTable = {1, 1, 1, 1, 1, 16, 2, 16, 13, 16, 16, 1}
  763.         -- ConfigTable Werte: Sprache, Auto-Einschalten, Zeit, Datum, Buttonfenster Farbe, Buttonfenster Textfarbe, Textfenster Textfarbe, Textfenster Textfarbe, Hintergrundfarbe Übersicht, Schriftfarbe Übersicht
  764.  
  765.         local configFile = io.open("Programmkonfiguration", "w")
  766.         configFile:write(textutils.serialise(configTable))
  767.         configFile:close()
  768.         term.setTextColor(colors.red)
  769.         print("Die Standardeinstellungen werden nun geladen!")
  770.         term.setTextColor(colors.white)
  771.         return configTable
  772.     end)
  773. }
  774.  
  775. function writeTextToWindow(windowName, windowLength, windowHeight, backgroundColor, textColor, text1, text1SetOffX, text1SetOffY, text2, text2SetOffX, text2SetOffY)
  776.  
  777.     if text2 == true then
  778.         text2 = "Aktiv"
  779.     elseif text2 == false then
  780.         text2 = "Inaktiv"
  781.     end
  782.  
  783.     windowName.setBackgroundColor(backgroundColor)
  784.     windowName.setTextColor(textColor)
  785.     windowName.clear()
  786.  
  787.     local textLength1 = string.len(text1)
  788.     local drawPositionX1
  789.     local drawPositionY1
  790.  
  791.     if text2 then
  792.         local textLength2 = string.len(text2)
  793.         local drawPositionX2
  794.         local drawPositionY2
  795.  
  796.         if text1SetOffX == "left" then
  797.             drawPositionX1 = 2
  798.         else
  799.             drawPositionX1 = (math.floor((windowLength - textLength1) / 2) + text1SetOffX)
  800.         end
  801.  
  802.         if text2SetOffX == "left" then
  803.             drawPositionX2 = 2
  804.         else
  805.             drawPositionX2 = (math.ceil((windowLength - textLength2) / 2) + text2SetOffX)
  806.         end
  807.  
  808.         if text1SetOffY == "split" then
  809.             drawPositionY1 = 2
  810.             drawPositionY2 = windowHeight
  811.         elseif windowHeight <= 3 then
  812.             drawPositionY1 = 1
  813.             drawPositionY2 = 2
  814.         elseif windowHeight == 4 then
  815.             drawPositionY1 = 2
  816.             drawPositionY2 = 3
  817.         else
  818.             if math.fmod(windowHeight / 2, 2) == 0 then
  819.                 drawPositionY1 = (windowHeight / 2) - 1 + text1SetOffY
  820.                 drawPositionY2 = drawPositionY1 + 2 + text2SetOffY
  821.             else
  822.                 drawPositionY1 = (math.floor(windowHeight / 2)) + text1SetOffY
  823.                 drawPositionY2 = drawPositionY1 + 2 + text2SetOffY
  824.             end
  825.         end
  826.  
  827.         windowName.setCursorPos(drawPositionX2 , drawPositionY2)
  828.         windowName.write(text2)
  829.         windowName.setCursorPos(drawPositionX1 , drawPositionY1)
  830.         windowName.write(text1)
  831.  
  832.     else
  833.         if text1SetOffX == "left" then
  834.             drawPositionX1 = 2
  835.         else
  836.             drawPositionX1 = (math.floor((windowLength - textLength1) / 2) + text1SetOffX)
  837.         end
  838.  
  839.         if math.fmod(windowHeight / 2, 2) == 0 then
  840.             drawPositionY1 = (windowHeight / 2) + text1SetOffY
  841.         else
  842.             drawPositionY1 = (math.ceil(windowHeight / 2)) + text1SetOffY
  843.         end
  844.  
  845.         windowName.setCursorPos(drawPositionX1 , drawPositionY1)
  846.         windowName.write(text1)
  847.     end
  848. end
  849.  
  850. windowCreate = {
  851.     foundation = (function()
  852.         backgroundButtonWindowInfo = {1, monitorHeight - 4, monitorWidth, 5}
  853.         backgroundButtonWindow = window.create(monitor, backgroundButtonWindowInfo[1], backgroundButtonWindowInfo[2], backgroundButtonWindowInfo[3], backgroundButtonWindowInfo[4])
  854.  
  855.         foundationWindowInfo = {1, 6, monitorWidth, monitorHeight - 10}
  856.         foundationWindow = window.create(monitor, foundationWindowInfo[1], foundationWindowInfo[2], foundationWindowInfo[3], foundationWindowInfo[4])
  857.  
  858.         usableWidth = foundationWindowInfo[3]
  859.         usableWidthHalf = math.ceil(foundationWindowInfo[3] / 2)
  860.         usableWidthHalfRest = foundationWindowInfo[3] - usableWidthHalf
  861.  
  862.         usableHeightFull = foundationWindowInfo[4]
  863.         usableHeightHalf = math.ceil(foundationWindowInfo[4] / 2)
  864.         usableHeightHalfRest = foundationWindowInfo[4] - usableHeightHalf
  865.  
  866.         usableHeight1 = math.ceil(foundationWindowInfo[4] / 4)
  867.         usableHeight2 = math.ceil((foundationWindowInfo[4] - usableHeight1) / 3)
  868.         usableHeight3 = math.ceil((foundationWindowInfo[4] - usableHeight1 - usableHeight2) / 2)
  869.         usableHeight4 = foundationWindowInfo[4] - usableHeight1 - usableHeight2 - usableHeight3
  870.     end),
  871.  
  872.     bootScreen = (function()
  873.         bootWindowInfo = {}
  874.         bootWindow = {}
  875.  
  876.         bootWindowInfo[1] = {1, 1, monitorWidth, monitorHeight}
  877.         bootWindowInfo[2] = {3, 3, monitorWidth - 4, monitorHeight - 4}
  878.         bootWindowInfo[3] = {4, 4, monitorWidth - 6, monitorHeight - 6}
  879.         bootWindowInfo[4] = {5, 5, monitorWidth - 8, monitorHeight - 8}
  880.         bootWindowInfo[5] = {6, 6, monitorWidth - 10, monitorHeight - 10}
  881.         bootWindowInfo[6] = {7, 7, monitorWidth - 12, monitorHeight - 12}
  882.         bootWindowInfo[7] = {8, 8, monitorWidth - 14, monitorHeight - 14}
  883.  
  884.         for i = 1, 7, 1 do
  885.             bootWindow[i] = window.create(monitor, bootWindowInfo[i][1], bootWindowInfo[i][2], bootWindowInfo[i][3], bootWindowInfo[i][4])
  886.         end
  887.     end),
  888.  
  889.     aboutAutor = (function()
  890.         aboutAutorWindowInfo = {1, 1, usableWidth, usableHeightFull + 5}
  891.  
  892.         aboutAutorWindow = window.create(monitor, aboutAutorWindowInfo[1], aboutAutorWindowInfo[2], aboutAutorWindowInfo[3], aboutAutorWindowInfo[4])
  893.     end),
  894.  
  895.     interface = (function()
  896.         leftButtonWindowInfo = {2, 2, 5, 3}
  897.         leftButtonWindow = window.create(backgroundButtonWindow, leftButtonWindowInfo[1], leftButtonWindowInfo[2], leftButtonWindowInfo[3], leftButtonWindowInfo[4])
  898.  
  899.         rightButtonWindowInfo = {backgroundButtonWindowInfo[3] - 5, 2, 5, 3}
  900.         rightButtonWindow = window.create(backgroundButtonWindow , rightButtonWindowInfo[1], rightButtonWindowInfo[2], rightButtonWindowInfo[3], rightButtonWindowInfo[4])
  901.  
  902.         if math.fmod(backgroundButtonWindowInfo[3], 2) == 0 then
  903.             leftCenterButtonWindowInfo = {8, 2 ,(backgroundButtonWindowInfo[3] / 2) - 8, 3}
  904.             leftCenterButtonWindow = window.create(backgroundButtonWindow, leftCenterButtonWindowInfo[1], leftCenterButtonWindowInfo[2], leftCenterButtonWindowInfo[3], leftCenterButtonWindowInfo[4])    
  905.  
  906.             rightCenterButtonWindowInfo = {(backgroundButtonWindowInfo[3] / 2) + 2, 2,(backgroundButtonWindowInfo[3] / 2) - 8, 3}
  907.             rightCenterButtonWindow = window.create(backgroundButtonWindow, rightCenterButtonWindowInfo[1], rightCenterButtonWindowInfo[2], rightCenterButtonWindowInfo[3], rightCenterButtonWindowInfo[4])
  908.  
  909.         else
  910.  
  911.             leftCenterButtonWindowInfo = {8, 2 ,math.floor(backgroundButtonWindowInfo[3] / 2) - 7, 3}
  912.             leftCenterButtonWindow = window.create(backgroundButtonWindow, leftCenterButtonWindowInfo[1], leftCenterButtonWindowInfo[2], leftCenterButtonWindowInfo[3], leftCenterButtonWindowInfo[4])    
  913.  
  914.             rightCenterButtonWindowInfo = {math.ceil(backgroundButtonWindowInfo[3] / 2) + 1, 2, math.floor(backgroundButtonWindowInfo[3] / 2) - 7, 3}
  915.             rightCenterButtonWindow = window.create(backgroundButtonWindow, rightCenterButtonWindowInfo[1], rightCenterButtonWindowInfo[2], rightCenterButtonWindowInfo[3], rightCenterButtonWindowInfo[4])
  916.         end
  917.  
  918.         optionButtonWindowInfo = {1, 1, 7, 5}
  919.         optionButtonWindow = window.create(monitor, optionButtonWindowInfo[1], optionButtonWindowInfo[2], optionButtonWindowInfo[3], optionButtonWindowInfo[4])
  920.  
  921.         timeTextWindowInfo = {monitorWidth - 11, 1, 12, 5}
  922.         timeTextWindow = window.create(monitor, timeTextWindowInfo[1], timeTextWindowInfo[2], timeTextWindowInfo[3], timeTextWindowInfo[4])
  923.        
  924.         headerTextWindowInfo = {optionButtonWindowInfo[3] + 1, 1, monitorWidth - optionButtonWindowInfo[3] - timeTextWindowInfo[3] , 5}
  925.         headerTextWindow = window.create(monitor, headerTextWindowInfo[1], headerTextWindowInfo[2], headerTextWindowInfo[3], headerTextWindowInfo[4])
  926.     end),
  927.  
  928.     optionMain = (function()
  929.  
  930.         optionMainWindowInfo = {}
  931.         optionMainWindow = {}
  932.  
  933.         optionMainWindowInfo[1] = {1, 1, usableWidth, usableHeight1}
  934.         optionMainWindowInfo[2] = {1, (1 + usableHeight1), usableWidth, usableHeight2}
  935.         optionMainWindowInfo[3] = {1, (1 + usableHeight1 + usableHeight2), usableWidth, usableHeight3}
  936.         optionMainWindowInfo[4] = {1, (1 + usableHeight1 + usableHeight2 + usableHeight3), usableWidth, usableHeight4}
  937.  
  938.         optionMainWindow[1] = window.create(foundationWindow, optionMainWindowInfo[1][1], optionMainWindowInfo[1][2], optionMainWindowInfo[1][3], optionMainWindowInfo[1][4])
  939.         optionMainWindow[2] = window.create(foundationWindow, optionMainWindowInfo[2][1], optionMainWindowInfo[2][2], optionMainWindowInfo[2][3], optionMainWindowInfo[2][4])
  940.         optionMainWindow[3] = window.create(foundationWindow, optionMainWindowInfo[3][1], optionMainWindowInfo[3][2], optionMainWindowInfo[3][3], optionMainWindowInfo[3][4])
  941.         optionMainWindow[4] = window.create(foundationWindow, optionMainWindowInfo[4][1], optionMainWindowInfo[4][2], optionMainWindowInfo[4][3], optionMainWindowInfo[4][4])
  942.     end),
  943.  
  944.     optionSetting = (function()
  945.         optionSettingWindowInfo = {4, 3, usableWidth - 5, 7}
  946.         optionSettingWindow = window.create(foundationWindow, optionSettingWindowInfo[1], optionSettingWindowInfo[2], optionSettingWindowInfo[3], optionSettingWindowInfo[4])
  947.     end),
  948.  
  949.     systemControl = (function()
  950.         systemControlWindowInfo = {}
  951.         systemControlWindow = {}
  952.  
  953.         systemControlWindowInfo[1] = {1, 1, usableWidthHalf, usableHeightHalf}
  954.         systemControlWindowInfo[2] = {1 + usableWidthHalf, 1, usableWidthHalfRest, usableHeightHalf}
  955.         systemControlWindowInfo[3] = {1 , 1 + usableHeightHalf, usableWidthHalf, usableHeightHalfRest}
  956.         systemControlWindowInfo[4] = {1 + usableWidthHalf, 1 + usableHeightHalf, usableWidthHalfRest, usableHeightHalfRest}
  957.  
  958.         systemControlWindow[1] = window.create(foundationWindow, systemControlWindowInfo[1][1], systemControlWindowInfo[1][2], systemControlWindowInfo[1][3], systemControlWindowInfo[1][4])
  959.         systemControlWindow[2] = window.create(foundationWindow, systemControlWindowInfo[2][1], systemControlWindowInfo[2][2], systemControlWindowInfo[2][3], systemControlWindowInfo[2][4])
  960.         systemControlWindow[3] = window.create(foundationWindow, systemControlWindowInfo[3][1], systemControlWindowInfo[3][2], systemControlWindowInfo[3][3], systemControlWindowInfo[3][4])
  961.         systemControlWindow[4] = window.create(foundationWindow, systemControlWindowInfo[4][1], systemControlWindowInfo[4][2], systemControlWindowInfo[4][3], systemControlWindowInfo[4][4])
  962.     end),
  963.  
  964.     pageMain = (function()
  965.         paigeMainWindow1Info = {1, 1, usableWidthHalf, usableHeight1}
  966.         paigeMainWindow2Info = {1 + usableWidthHalf, 1, usableWidthHalfRest, usableHeight1}
  967.         paigeMainWindow3Info = {1, (1 + usableHeight1), usableWidthHalf, usableHeight2}
  968.         paigeMainWindow4Info = {1 + usableWidthHalf, (1 + usableHeight1), usableWidthHalfRest, usableHeight2}
  969.         paigeMainWindow5Info = {1, (1 + usableHeight1 + usableHeight2), usableWidthHalf, usableHeight3}
  970.         paigeMainWindow6Info = {1 + usableWidthHalf, (1 + usableHeight1 + usableHeight2), usableWidthHalfRest, usableHeight3}
  971.         paigeMainWindow7Info = {1, (1 + usableHeight1 + usableHeight2 + usableHeight3), usableWidthHalf, usableHeight4}
  972.         paigeMainWindow8Info = {1 + usableWidthHalf, (1 + usableHeight1 + usableHeight2 + usableHeight3), usableWidthHalfRest, usableHeight4}
  973.  
  974.         paigeMainWindow1 = window.create(foundationWindow, paigeMainWindow1Info[1], paigeMainWindow1Info[2], paigeMainWindow1Info[3], paigeMainWindow1Info[4])
  975.         paigeMainWindow2 = window.create(foundationWindow, paigeMainWindow2Info[1], paigeMainWindow2Info[2], paigeMainWindow2Info[3], paigeMainWindow2Info[4])
  976.         paigeMainWindow3 = window.create(foundationWindow, paigeMainWindow3Info[1], paigeMainWindow3Info[2], paigeMainWindow3Info[3], paigeMainWindow3Info[4])
  977.         paigeMainWindow4 = window.create(foundationWindow, paigeMainWindow4Info[1], paigeMainWindow4Info[2], paigeMainWindow4Info[3], paigeMainWindow4Info[4])
  978.         paigeMainWindow5 = window.create(foundationWindow, paigeMainWindow5Info[1], paigeMainWindow5Info[2], paigeMainWindow5Info[3], paigeMainWindow5Info[4])
  979.         paigeMainWindow6 = window.create(foundationWindow, paigeMainWindow6Info[1], paigeMainWindow6Info[2], paigeMainWindow6Info[3], paigeMainWindow6Info[4])
  980.         paigeMainWindow7 = window.create(foundationWindow, paigeMainWindow7Info[1], paigeMainWindow7Info[2], paigeMainWindow7Info[3], paigeMainWindow7Info[4])
  981.         paigeMainWindow8 = window.create(foundationWindow, paigeMainWindow8Info[1], paigeMainWindow8Info[2], paigeMainWindow8Info[3], paigeMainWindow8Info[4])
  982.     end),
  983.  
  984.     pageRF = (function()
  985.         pageRFWindowInfo = {}
  986.         pageRFWindow = {}
  987.  
  988.         pageRFWindowInfo[1] = {1, 1, 11, usableHeightFull - 1}
  989.         pageRFWindowInfo[2] = {5, 2, 3, usableHeightFull - 2}
  990.         pageRFWindowInfo[3] = {6, usableHeightFull - (math.ceil((storedRFRaw / capacityRFRaw) * (usableHeightFull - 2))), 1, (math.ceil((storedRFRaw / capacityRFRaw) * (usableHeightFull - 2)))}
  991.         pageRFWindowInfo[4] = {1, usableHeightFull, 11, 1}
  992.         pageRFWindowInfo[5] = {12, 1, usableWidth - 11, math.ceil(usableHeightFull / 3)}
  993.         pageRFWindowInfo[6] = {12, pageRFWindowInfo[5][4] + 1, usableWidth - 11, math.ceil((usableHeightFull - pageRFWindowInfo[5][4]) / 2)}
  994.         pageRFWindowInfo[7] = {12, pageRFWindowInfo[5][4] + pageRFWindowInfo[6][4] + 1, usableWidth - 11, usableHeightFull - pageRFWindowInfo[5][4] - pageRFWindowInfo[6][4]}
  995.  
  996.         pageRFWindow[1] = window.create(foundationWindow, pageRFWindowInfo[1][1], pageRFWindowInfo[1][2], pageRFWindowInfo[1][3], pageRFWindowInfo[1][4])
  997.         pageRFWindow[2] = window.create(foundationWindow, pageRFWindowInfo[2][1], pageRFWindowInfo[2][2], pageRFWindowInfo[2][3], pageRFWindowInfo[2][4])
  998.         pageRFWindow[3] = window.create(foundationWindow, pageRFWindowInfo[3][1], pageRFWindowInfo[3][2], pageRFWindowInfo[3][3], pageRFWindowInfo[3][4])
  999.         pageRFWindow[4] = window.create(foundationWindow, pageRFWindowInfo[4][1], pageRFWindowInfo[4][2], pageRFWindowInfo[4][3], pageRFWindowInfo[4][4])
  1000.         pageRFWindow[5] = window.create(foundationWindow, pageRFWindowInfo[5][1], pageRFWindowInfo[5][2], pageRFWindowInfo[5][3], pageRFWindowInfo[5][4])
  1001.         pageRFWindow[6] = window.create(foundationWindow, pageRFWindowInfo[6][1], pageRFWindowInfo[6][2], pageRFWindowInfo[6][3], pageRFWindowInfo[6][4])
  1002.         pageRFWindow[7] = window.create(foundationWindow, pageRFWindowInfo[7][1], pageRFWindowInfo[7][2], pageRFWindowInfo[7][3], pageRFWindowInfo[7][4])
  1003.     end),
  1004.  
  1005.     pageFuel = (function()
  1006.         pageFuelWindowInfo = {}
  1007.         pageFuelWindow = {}
  1008.  
  1009.         pageFuelWindowInfo[1] = {1, 1, 11, usableHeightFull - 1}
  1010.         pageFuelWindowInfo[2] = {5, 2, 3, usableHeightFull - 2}
  1011.  
  1012.         pageFuelWindowInfo[3] = {6, usableHeightFull - (math.ceil((fuelAmountRaw / fuelTankCapacity) * (usableHeightFull - 2))), 1, (math.ceil((fuelAmountRaw / fuelTankCapacity) * (usableHeightFull - 2)))}
  1013.         pageFuelWindowInfo[4] = {1, usableHeightFull, 11, 1}
  1014.         pageFuelWindowInfo[5] = {12, 1, usableWidth - 11, math.ceil(usableHeightFull / 3)}
  1015.         pageFuelWindowInfo[6] = {12, pageFuelWindowInfo[5][4] + 1, usableWidth - 11, math.ceil((usableHeightFull - pageFuelWindowInfo[5][4]) / 2)}
  1016.         pageFuelWindowInfo[7] = {12, pageFuelWindowInfo[5][4] + pageFuelWindowInfo[6][4] + 1, usableWidth - 11, usableHeightFull - pageFuelWindowInfo[5][4] - pageFuelWindowInfo[6][4]}
  1017.  
  1018.         pageFuelWindow[1] = window.create(foundationWindow, pageFuelWindowInfo[1][1], pageFuelWindowInfo[1][2], pageFuelWindowInfo[1][3], pageFuelWindowInfo[1][4])
  1019.         pageFuelWindow[2] = window.create(foundationWindow, pageFuelWindowInfo[2][1], pageFuelWindowInfo[2][2], pageFuelWindowInfo[2][3], pageFuelWindowInfo[2][4])
  1020.         pageFuelWindow[3] = window.create(foundationWindow, pageFuelWindowInfo[3][1], pageFuelWindowInfo[3][2], pageFuelWindowInfo[3][3], pageFuelWindowInfo[3][4])
  1021.         pageFuelWindow[4] = window.create(foundationWindow, pageFuelWindowInfo[4][1], pageFuelWindowInfo[4][2], pageFuelWindowInfo[4][3], pageFuelWindowInfo[4][4])
  1022.         pageFuelWindow[5] = window.create(foundationWindow, pageFuelWindowInfo[5][1], pageFuelWindowInfo[5][2], pageFuelWindowInfo[5][3], pageFuelWindowInfo[5][4])
  1023.         pageFuelWindow[6] = window.create(foundationWindow, pageFuelWindowInfo[6][1], pageFuelWindowInfo[6][2], pageFuelWindowInfo[6][3], pageFuelWindowInfo[6][4])
  1024.         pageFuelWindow[7] = window.create(foundationWindow, pageFuelWindowInfo[7][1], pageFuelWindowInfo[7][2], pageFuelWindowInfo[7][3], pageFuelWindowInfo[7][4])
  1025.     end),
  1026.  
  1027.  
  1028.     pageEfficiency = (function()
  1029.  
  1030.         pageEfficiencyWindowInfo = {}
  1031.         pageEfficiencyWindow = {}
  1032.  
  1033.         pageEfficiencyWindowInfo[1] = {1, 1, usableWidth, math.ceil(usableHeightFull / 3)}
  1034.         pageEfficiencyWindowInfo[2] = {1, pageEfficiencyWindowInfo[1][4] + 1, usableWidthHalf, math.ceil((usableHeightFull - pageEfficiencyWindowInfo[1][4]) / 2)}
  1035.         pageEfficiencyWindowInfo[3] = {usableWidthHalf + 1, pageEfficiencyWindowInfo[1][4] + 1, usableWidthHalfRest, math.ceil((usableHeightFull - pageEfficiencyWindowInfo[1][4]) / 2)}
  1036.         pageEfficiencyWindowInfo[4] = {1, pageEfficiencyWindowInfo[1][4] + pageEfficiencyWindowInfo[2][4] + 1, usableWidthHalf, usableHeightFull - pageEfficiencyWindowInfo[1][4] - pageEfficiencyWindowInfo[2][4]}
  1037.         pageEfficiencyWindowInfo[5] = {usableWidthHalf + 1, pageEfficiencyWindowInfo[1][4] + pageEfficiencyWindowInfo[2][4] + 1, usableWidthHalfRest, usableHeightFull - pageEfficiencyWindowInfo[1][4] - pageEfficiencyWindowInfo[2][4]}
  1038.  
  1039.         pageEfficiencyWindow[1] = window.create(foundationWindow, pageEfficiencyWindowInfo[1][1], pageEfficiencyWindowInfo[1][2], pageEfficiencyWindowInfo[1][3], pageEfficiencyWindowInfo[1][4])
  1040.         pageEfficiencyWindow[2] = window.create(foundationWindow, pageEfficiencyWindowInfo[2][1], pageEfficiencyWindowInfo[2][2], pageEfficiencyWindowInfo[2][3], pageEfficiencyWindowInfo[2][4])
  1041.         pageEfficiencyWindow[3] = window.create(foundationWindow, pageEfficiencyWindowInfo[3][1], pageEfficiencyWindowInfo[3][2], pageEfficiencyWindowInfo[3][3], pageEfficiencyWindowInfo[3][4])
  1042.         pageEfficiencyWindow[4] = window.create(foundationWindow, pageEfficiencyWindowInfo[4][1], pageEfficiencyWindowInfo[4][2], pageEfficiencyWindowInfo[4][3], pageEfficiencyWindowInfo[4][4])
  1043.         pageEfficiencyWindow[5] = window.create(foundationWindow, pageEfficiencyWindowInfo[5][1], pageEfficiencyWindowInfo[5][2], pageEfficiencyWindowInfo[5][3], pageEfficiencyWindowInfo[5][4])
  1044.  
  1045.     end),
  1046. }
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052. display = {
  1053.     bootScreen = (function(text)
  1054.     colorBackground = colors.white
  1055.         for i = 1, 7, 1 do
  1056.             if colorBackground == colors.white then
  1057.                 colorBackground = colors.black
  1058.             else
  1059.                 colorBackground = colors.white
  1060.             end
  1061.             bootWindow[i].setBackgroundColor(colorBackground)
  1062.             bootWindow[i].clear()
  1063.         end
  1064.  
  1065.         writeTextToWindow(bootWindow[7], bootWindowInfo[7][3], bootWindowInfo[7][4], colors.black, colors.white, text, 1, 0)
  1066.     end),
  1067.  
  1068.     interface = (function(leftCenterButtonText, rightCenterButtonText)
  1069.         if leftCenterButtonText == nil then
  1070.             leftCenterButtonText = "unbelegt"
  1071.         end
  1072.         if rightCenterButtonText == nil then
  1073.             rightCenterButtonText  = "unbelegt"
  1074.         end
  1075.  
  1076.         backgroundButtonWindow.setBackgroundColor(backgroundWindowBackgroundColor)
  1077.         backgroundButtonWindow.clear()
  1078.         writeTextToWindow(rightButtonWindow, rightButtonWindowInfo[3], rightButtonWindowInfo[4], buttonWindowBackgroundColor, buttonWindowTextColor, ">" , 1, 0)
  1079.         writeTextToWindow(leftButtonWindow, leftButtonWindowInfo[3], leftButtonWindowInfo[4], buttonWindowBackgroundColor, buttonWindowTextColor, "<", 1, 0)
  1080.         writeTextToWindow(leftCenterButtonWindow, leftCenterButtonWindowInfo[3], leftCenterButtonWindowInfo[4], buttonWindowBackgroundColor, buttonWindowTextColor, leftCenterButtonText, 1, 0)
  1081.         writeTextToWindow(rightCenterButtonWindow, rightCenterButtonWindowInfo[3], rightCenterButtonWindowInfo[4], buttonWindowBackgroundColor, buttonWindowTextColor, rightCenterButtonText, 1, 0)
  1082.         writeTextToWindow(optionButtonWindow, optionButtonWindowInfo[3], optionButtonWindowInfo[4], buttonWindowBackgroundColor, buttonWindowTextColor, "Menü", 1, 0)
  1083.  
  1084.         writeTextToWindow(timeTextWindow, timeTextWindowInfo[3], timeTextWindowInfo[4], textWindowBackgroundColor, textWindowTextColor, dayTime, 0, 0, dateTime, 0, 0)
  1085.  
  1086.         writeTextToWindow(headerTextWindow, headerTextWindowInfo[3], headerTextWindowInfo[4], textWindowBackgroundColor, textWindowTextColor, "Stavros - Reaktorsteuerung", 2, 0, pageHeader, 2, 0)
  1087.     end),
  1088.  
  1089.  
  1090. --[[
  1091. In dieser Funktion wird die "Über den Autor" Seite geladen und angezeigt.
  1092. ]]
  1093.  
  1094.     aboutAutor = (function()
  1095.         aboutAutorWindow.setBackgroundColor(colors.black)
  1096.         aboutAutorWindow.setTextColor(colors.white)
  1097.         aboutAutorWindow.clear()
  1098.  
  1099.         for i = 1, 14, 1 do
  1100.             aboutAutorWindow.setCursorPos(1 + (math.ceil((aboutAutorWindowInfo[3] - string.len(aboutAutorText[i])) / 2)), ((aboutAutorWindowInfo[4] - 14) / 2) + i)
  1101.             aboutAutorWindow.write(aboutAutorText[i])
  1102.         end
  1103.     end),
  1104.  
  1105.     optionMain = (function()
  1106.         foundationWindow.setBackgroundColor(colors.red)
  1107.         foundationWindow.clear()
  1108.  
  1109.         local counter1 = 1
  1110.         local counter2 = 1
  1111.         local colorBackground
  1112.  
  1113.         if currentOptionPage == 2 then
  1114.             counter1 = counter1 + 4
  1115.         elseif currentOptionPage == 3 then
  1116.             counter1 = counter1 + 8
  1117.         end
  1118.  
  1119.         for i = counter1, (counter1 + 3), 1 do
  1120.             if currentOptionPage == 1 or currentOptionPage == 3 then
  1121.                 if (counter2 / 2) == math.ceil(counter2 / 2) then
  1122.                     colorBackground = colors.gray
  1123.                 else
  1124.                     colorBackground = colors.black
  1125.                 end
  1126.  
  1127.             elseif currentOptionPage == 2 then
  1128.                 if (counter2 / 2) == math.ceil(counter2 / 2) then
  1129.                     colorBackground = colors.black
  1130.                 else
  1131.                     colorBackground = colors.gray
  1132.                 end
  1133.             end
  1134.  
  1135.             writeTextToWindow(optionMainWindow[counter2], optionMainWindowInfo[counter2][3], optionMainWindowInfo[counter2][4], colorBackground, colors.white, configTableInfo[i], "left", 0, configTableText[i][configTable[i]], 1, 0)
  1136.             counter2 = counter2 + 1
  1137.         end
  1138.     end),
  1139.  
  1140.     optionSettingEntry = (function(i)
  1141.         if currentOptionPage == 2 then
  1142.             i = i + 4
  1143.         elseif currentOptionPage == 3 then
  1144.             i = i + 8
  1145.         end
  1146.  
  1147.         if (configTable[i] + configTableManipulator) > (table.getn(configTableText[i])) then
  1148.             configTableManipulator = configTableManipulator - table.getn(configTableText[i])
  1149.         elseif (configTable[i] + configTableManipulator) < 1 then
  1150.             configTableManipulator = configTableManipulator + table.getn(configTableText[i])
  1151.         end
  1152.  
  1153.         foundationWindow.setBackgroundColor(colors.black)
  1154.         foundationWindow.clear()
  1155.  
  1156.         writeTextToWindow(optionSettingWindow, optionSettingWindowInfo[3], optionSettingWindowInfo[4], colors.black, colors.white,     configTableInfo[i], 1, 0, configTableText[i][configTable[i] + configTableManipulator], 1, 0)
  1157.         selectedConfig = i
  1158.         newConfigValue = (configTable[i] + configTableManipulator)
  1159.     end),
  1160.  
  1161.  
  1162.     systemControl = (function()
  1163.         foundationWindow.setBackgroundColor(colors.white)
  1164.         foundationWindow.clear()
  1165.  
  1166.         for i = 1, 4, 1 do
  1167.             local setOff = 0
  1168.             local colorBackground = colors.black
  1169.  
  1170.             if i == 2 or i == 3 then
  1171.                 colorBackground = colors.lightGray
  1172.             elseif SystemControlText[currentSettingsPage][i][1] == "Reaktor" and reactorActive == false then
  1173.                 setOff = setOff + 1
  1174.             end
  1175.  
  1176.             writeTextToWindow(systemControlWindow[i], systemControlWindowInfo[i][3], systemControlWindowInfo[i][4], colorBackground, colors.white, SystemControlText[currentSettingsPage][i][1], 1, 0, SystemControlText[currentSettingsPage][i][2 + setOff], 1, 0)
  1177.  
  1178.         end
  1179.     end),
  1180.  
  1181.     pageMain = (function()
  1182.         foundationWindow.setBackgroundColor(colors.white)
  1183.         foundationWindow.clear()
  1184.  
  1185.         writeTextToWindow(paigeMainWindow1, paigeMainWindow1Info[3], paigeMainWindow1Info[4], paigeMainBackgroundColor, paigeMainTextColor, "Reaktor ist:", 0, 0, reactorActive, 0, 0)
  1186.  
  1187.         if activeCooling ~= true then
  1188.             writeTextToWindow(paigeMainWindow2, paigeMainWindow2Info[3], paigeMainWindow2Info[4], paigeMainBackgroundColor, paigeMainTextColor, "Reaktor arbeitet:", 0, 0, "Passiv gekühlt", 0, 0)
  1189.         else
  1190.             writeTextToWindow(paigeMainWindow2, paigeMainWindow2Info[3], paigeMainWindow2Info[4], paigeMainBackgroundColor, paigeMainTextColor, "Reaktor arbeitet:", 0, 0, "Aktiv gekühlt", 0, 0)
  1191.         end
  1192.  
  1193.         writeTextToWindow(paigeMainWindow3, paigeMainWindow3Info[3], paigeMainWindow3Info[4], paigeMainBackgroundColor, paigeMainTextColor, "Reaktorspeicher:", 0, 0, storedRF[1] .. storedRF[2] .. " gespeichert", 0, 0)
  1194.  
  1195.         writeTextToWindow(paigeMainWindow4, paigeMainWindow4Info[3], paigeMainWindow4Info[4], paigeMainBackgroundColor, paigeMainTextColor, "Reaktorspeicher zu:", 0, 0, math.ceil((storedRFRaw / capacityRFRaw) * 100) .. "% voll", 0, 0)
  1196.  
  1197.         writeTextToWindow(paigeMainWindow5, paigeMainWindow5Info[3], paigeMainWindow5Info[4], paigeMainBackgroundColor, paigeMainTextColor, "Brennstoff Verbrauch:", 0, 0, fuelburnedLastTick[1] .. fuelburnedLastTick[2], 0, 0)
  1198.  
  1199.         writeTextToWindow(paigeMainWindow6, paigeMainWindow6Info[3], paigeMainWindow6Info[4], paigeMainBackgroundColor, paigeMainTextColor, "Brennstoff-Effizienz:", 0, 0, passivEfficiency[1] .. passivEfficiency[2], 0, 0)
  1200.  
  1201.         writeTextToWindow(paigeMainWindow7, paigeMainWindow7Info[3], paigeMainWindow7Info[4], paigeMainBackgroundColor, paigeMainTextColor, "Brennstofffüllstand", 0, 0, fuelAmountPercent .. " % - " .. fuelAmount[1] .. fuelAmount[2], 0, 0)
  1202.  
  1203.         writeTextToWindow(paigeMainWindow8, paigeMainWindow8Info[3], paigeMainWindow8Info[4], paigeMainBackgroundColor, paigeMainTextColor, "Steuerstab-Einschub", 0, 0, "Zu " .. getControlRodLevel .. "% eingeschoben", 0, 0)
  1204.     end),
  1205.  
  1206.     pageRF = (function()
  1207.         foundationWindow.clear()
  1208.         writeTextToWindow(pageRFWindow[1], pageRFWindowInfo[1][3], pageRFWindowInfo[1][4], colors.black, colors.white, "100%", -2, "split", "0%" , -2, "split")
  1209.         pageRFWindow[2].setBackgroundColor(colors.lightGray)
  1210.         pageRFWindow[2].clear()
  1211.         pageRFWindow[3].setBackgroundColor(colors.red)
  1212.         pageRFWindow[3].clear()
  1213.         writeTextToWindow(pageRFWindow[4], pageRFWindowInfo[4][3], pageRFWindowInfo[4][4], colors.black, colors.white, "RF-Speicher", 1, 0)
  1214.         writeTextToWindow(pageRFWindow[5], pageRFWindowInfo[5][3], pageRFWindowInfo[5][4], colors.black, colors.white, "Energieproduktion", 1, 0, producedRFLastTick[1] .. producedRFLastTick[2] , 0, 0)
  1215.         writeTextToWindow(pageRFWindow[6], pageRFWindowInfo[6][3], pageRFWindowInfo[6][4], colors.black, colors.white, "Energiespeichergröße des Reaktors", 0, 0, capacityRF[1] .. capacityRF[2], 0, 0)
  1216.         writeTextToWindow(pageRFWindow[7], pageRFWindowInfo[7][3], pageRFWindowInfo[7][4], colors.black, colors.white, "RF-Produktion der letzten 5 Minuten", 1, 0, rfProducedHistorySum[1] .. rfProducedHistorySum[2] , 0, 0)
  1217.     end),
  1218.  
  1219.     pageFuel = (function()
  1220.         foundationWindow.clear()
  1221.         writeTextToWindow(pageFuelWindow[1], pageFuelWindowInfo[1][3], pageFuelWindowInfo[1][4], colors.black, colors.white, "100%", -2, "split", "0%" , -2, "split")
  1222.         pageFuelWindow[2].setBackgroundColor(colors.lightGray)
  1223.         pageFuelWindow[2].clear()
  1224.         pageFuelWindow[3].setBackgroundColor(colors.red)
  1225.         pageFuelWindow[3].clear()
  1226.         writeTextToWindow(pageFuelWindow[4], pageFuelWindowInfo[4][3], pageFuelWindowInfo[4][4], colors.black, colors.white, "Brennstoff", 1, 0)
  1227.  
  1228.         writeTextToWindow(pageFuelWindow[5], pageFuelWindowInfo[5][3], pageFuelWindowInfo[5][4], colors.black, colors.white, "Brennstoffverbrauch", 1, 0, fuelburnedLastTick[1] .. fuelburnedLastTick[2] , 0, 0)
  1229.         writeTextToWindow(pageFuelWindow[6], pageFuelWindowInfo[6][3], pageFuelWindowInfo[6][4], colors.black, colors.white, "Brennstoffaufnahme des Reaktors", 0, 0, fuelAmount[1] .. fuelAmount[2], 0, 0)
  1230.         writeTextToWindow(pageFuelWindow[7], pageFuelWindowInfo[7][3], pageFuelWindowInfo[7][4], colors.black, colors.white, "Brennstoffbedarf der letzten 5 Minuten", 1, 0, fuelBurnedHistorySum[1] .. fuelBurnedHistorySum[2] , 0, 0)
  1231.     end),
  1232.  
  1233.  
  1234.     pageEfficiency = (function()
  1235.  
  1236.         foundationWindow.setBackgroundColor(colors.white)
  1237.         foundationWindow.clear()
  1238.  
  1239.         local tempDifferenceValue
  1240.         local tempDifferenceText
  1241.         tempDifferenceValue = 1293 - fuelTemperature
  1242.  
  1243.         if reactorActive == true then
  1244.             if tempDifferenceValue < 0 then
  1245.                 tempDifferenceText = "Reaktor arbeitet " .. (tempDifferenceValue * -1) .. " K über Soll-Temperatur"
  1246.             elseif tempDifferenceValue > 0 then
  1247.                 tempDifferenceText = "Reaktor arbeitet " .. tempDifferenceValue .. " K unter Soll-Temperatur"
  1248.             else
  1249.                 tempDifferenceText = "Reaktor arbeitet in der Soll-Temperatur"
  1250.             end
  1251.         else
  1252.             tempDifferenceText = "Der Reaktor ist im Moment ausgeschaltet"
  1253.         end
  1254.  
  1255.         writeTextToWindow(pageEfficiencyWindow[1], pageEfficiencyWindowInfo[1][3], pageEfficiencyWindowInfo[1][4], colors.black, colors.white, tempDifferenceText, 1, 0)
  1256.  
  1257.         writeTextToWindow(pageEfficiencyWindow[2], pageEfficiencyWindowInfo[2][3], pageEfficiencyWindowInfo[2][4], colors.black, colors.white, "Ist-Betriebstemperatur:", 1, 0, fuelTemperature .. " K", 1 ,0)
  1258.  
  1259.         writeTextToWindow(pageEfficiencyWindow[3], pageEfficiencyWindowInfo[3][3], pageEfficiencyWindowInfo[3][4], colors.black, colors.white, "Soll-Betriebstemperatur:", 1, 0, 1293 .. " K", 1 ,0)
  1260.  
  1261.         writeTextToWindow(pageEfficiencyWindow[4], pageEfficiencyWindowInfo[4][3], pageEfficiencyWindowInfo[4][4], colors.black, colors.white, "Brennstoff-Effizienz", 1, 0, string.format("%.1f", fuelReactivity * 100) .. " %", 1 ,0)
  1262.  
  1263.         writeTextToWindow(pageEfficiencyWindow[5], pageEfficiencyWindowInfo[5][3], pageEfficiencyWindowInfo[5][4], colors.black, colors.white, "Brennstoff-Verbrauch:", 1, 0, fuelburnedLastTick[1] .. fuelburnedLastTick[2], 1 ,0)
  1264.  
  1265.     end),
  1266. }
  1267.  
  1268. function touchCheck(input1, input2, infoTable, offSetY)
  1269.     if offSetY == nil then
  1270.         offSetY = 0
  1271.     end
  1272.     if input1 >= infoTable[1] and input1 <= (infoTable[1] + infoTable[3] - 1) and input2 >= (infoTable[2] + offSetY) and input2 <= (infoTable[2] + infoTable[4] - 1 + offSetY) then
  1273.         return true
  1274.     else
  1275.         return false
  1276.     end
  1277. end
  1278.  
  1279. function reactorAutostart()
  1280.     if autostart == true and reactorActive == false then
  1281.         setActive(true)
  1282.     end
  1283. end
  1284.  
  1285. function baseTask()
  1286.     timerID = os.startTimer(1)
  1287.  
  1288.     if debugLevel == 0 then
  1289.         handler(globalVariables)
  1290.     elseif debugLevel == 1 then
  1291.         globalVariables()
  1292.     end
  1293.  
  1294.     if debugLevel == 0 then
  1295.         handler(alarmTrigger)
  1296.     elseif debugLevel == 1 then
  1297.         alarmTrigger()
  1298.     end
  1299.  
  1300.  
  1301.     controlRodSteeringTimer = controlRodSteeringTimer + 1
  1302.     if controlRodSteeringTimer >= 4 then
  1303.         if debugLevel == 0 then
  1304.             handler(controlRodSteering)
  1305.         elseif debugLevel == 1 then
  1306.             controlRodSteering()
  1307.         end
  1308.     end
  1309. end
  1310.  
  1311. function handler(functionName)
  1312.     if pcall(functionName) then
  1313.     else
  1314.         term.clear()
  1315.         term.setCursorPos(1, 1)
  1316.         printError("Warnung\n\nFehler bei der Reaktoranbindung aufgetreten!\nBitte Verbindung überprüfen!\n\nSystem wird in 30 Sekunden neugestartet...")
  1317.         display.bootScreen("! Fehler bei Programmstart !")
  1318.         os.sleep(30)
  1319.         os.reboot()
  1320.     end
  1321. end
  1322.  
  1323. function pageCheck()
  1324.     if page < 1 then
  1325.         page = 4
  1326.     elseif page > 4 then
  1327.         page = 1
  1328.     end
  1329. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement