Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function get_geraet(geraet)
- pList = peripheral.getNames()
- for i, name in pairs(pList) do
- if peripheral.getType(name) == geraet then
- return peripheral.wrap(name)
- end
- end
- return nil
- end
- function printXY(X, Y, farbe, text)
- mon.setCursorPos(X,Y)
- mon.setTextColour(farbe)
- mon.write(text)
- end
- verbrauch_array = {}
- for i = 1, 20 do
- verbrauch_array[i] = 0
- end
- leistung_array = {}
- for i = 1, 20 do
- leistung_array[i] = 0
- end
- while true do
- reactor = get_geraet("BigReactors-Reactor")
- mon = get_geraet("monitor")
- -- Regelgrössen für den Reaktor
- speicher_min = 20
- speicher_max = 80
- -- Regelung des Reaktors
- -- reactor.setAllControlRodLevels(100)
- speicher = math.floor(reactor.getEnergyStored() / 10000000 * 100)
- if speicher < speicher_min then
- cooling_level = 0
- elseif speicher > speicher_max then
- cooling_level = 100
- else
- cooling_level = math.abs(((speicher - speicher_min) / (speicher_max - speicher_min)) * 100)
- end
- -- leistung_ges = (100 - cooling_level) * reactor.getNumberOfControlRods()
- -- rod_counter = 0
- -- repeat
- -- if leistung_ges > 50 then
- -- reactor.setControlRodLevel(rod_counter, 50)
- -- leistung_ges = leistung_ges - 50
- -- else
- -- reactor.setControlRodLevel(rod_counter, 100 - leistung_ges)
- -- leistung_ges = 0
- -- end
- -- rod_counter = rod_counter + 1
- -- until leistung_ges <= 0
- reactor.setAllControlRodLevels(math.floor(cooling_level))
- -- Ab jetzt nurnoch Anzeigen der Werte
- term.clear()
- term.setCursorPos(1,1)
- term.write("Steuerprogram für den Reaktor")
- term.setCursorPos(1,3)
- term.write("Zum Beenden Strg + T halten")
- term.setCursorPos(1,5)
- term.write(textutils.formatTime(os.time(), true))
- assert ( get_geraet("BigReactors-Reactor"), "Kein Reaktor gefunden")
- assert ( get_geraet("monitor"), "Kein Monitor gefunden")
- mon.setBackgroundColor(colors.black)
- mon.setTextScale(0.8)
- mon.clear()
- zeile = 1
- printXY(32, zeile, colors.yellow, textutils.formatTime(os.time(), true))
- printXY(1, zeile, colors.white, "CommLink: ")
- if reactor.getConnected() then
- printXY(11, zeile, colors.green, "UP")
- else
- printXY(11, zeile, colors.red, "DOWN")
- end
- zeile = 2
- printXY(1, zeile, colors.white, "Reaktor: ")
- if reactor.getActive() then
- printXY(10, zeile, colors.green, "AN @ " .. string.format("%d", reactor.getCasingTemperature()) .. "°C")
- else
- printXY(10, zeile, colors.red, "AUS")
- end
- zeile = 4
- printXY(1, zeile, colors.white, "Interner Speicher:")
- if speicher < speicher_min then
- printXY(20, zeile, colors.orange, string.format("%d", speicher) .. "%")
- elseif speicher > speicher_max then
- printXY(20, zeile, colors.blue, string.format("%d", speicher) .."%")
- else
- printXY(20, zeile, colors.green, string.format("%d", speicher) .. "%")
- end
- zeile = 5
- table.insert(leistung_array, 1, reactor.getEnergyProducedLastTick())
- table.remove(leistung_array)
- leistung = 0
- for i = 1, table.getn(leistung_array) do
- leistung = leistung + leistung_array[i]
- end
- leistung = leistung / table.getn(leistung_array)
- printXY(1, zeile, colors.white, "Leistung:")
- printXY(11, zeile, colors.white, string.format("%d", leistung) .. " RF/t @ " .. string.format("%d", reactor.getFuelReactivity()) .. "%")
- zeile = 7
- printXY(1, zeile, colors.white, "Brennstoff:")
- brennstoff = reactor.getFuelAmount() / reactor.getFuelAmountMax() * 100
- if brennstoff > 80 then
- printXY(13, zeile, colors.green, string.format("%d", brennstoff) .. "%")
- elseif brennstoff < 20 then
- printXY(13, zeile, colors.red, string.format("%d", brennstoff))
- else
- printXY(13, zeile, colors.orange, string.format("%d", brennstoff))
- end
- zeile = 8
- table.insert(verbrauch_array, 1, reactor.getFuelConsumedLastTick())
- table.remove(verbrauch_array)
- verbrauch = 0
- for i = 1, table.getn(verbrauch_array) do
- verbrauch = verbrauch + verbrauch_array[i]
- end
- verbrauch = verbrauch / table.getn(verbrauch_array)
- printXY(1, zeile, colors.white, "Verbrauch:")
- printXY(12, zeile, colors.cyan, string.format("%d", verbrauch * 1000) / 1000 .. " mB/t @ " .. string.format("%d", reactor.getFuelTemperature()) .. "°C")
- zeile = 9
- printXY(1, zeile, colors.white, "Lebensdauer:")
- printXY(14, zeile, colors.cyan, string.format("%d", 1/(verbrauch*0.02)) .. " s/Ingot")
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement