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