-- Konfiguration
local reactorName = "BiggerReactors_Reactor_0"
local monitorName = "monitor_0"
local maxEnergy = 10000000 -- Maximaler Energiespeicher (für Prozentanzeige)
-- Initialisierung
local monitor = peripheral.wrap(monitorName)
local reactor = peripheral.wrap(reactorName)
if not reactor then
error("Reaktor nicht gefunden! Bitte Peripheral-Namen prüfen.")
end
-- Farben und Status
local autostart = false
local status = "Aus"
local toggleReactor = true
-- Hilfsfunktionen
local function clearScreen()
monitor.setBackgroundColor(colors.black)
monitor.clear()
monitor.setCursorPos(1, 1)
end
local function getReactorData()
local energyStats = reactor.getEnergyStats()
local energy = energyStats.energyStored
local fuel = reactor.getFuelAmount().amount
local fuelHeat = reactor.getFuelTemperature()
local casingHeat = reactor.getCasingTemperature()
local rfPerTick = reactor.getEnergyProducedLastTick()
local active = reactor.getActive()
return {
energy = energy,
fuel = fuel,
fuelHeat = fuelHeat,
casingHeat = casingHeat,
rfPerTick = rfPerTick,
active = active
}
end
local function displayHeader()
monitor.setBackgroundColor(colors.blue)
monitor.setTextColor(colors.white)
monitor.setCursorPos(1, 1)
monitor.write(" Bigger Reactor Monitor ")
monitor.setCursorPos(25, 1)
monitor.write(textutils.formatTime(os.time(), true))
monitor.setBackgroundColor(colors.black)
monitor.setTextColor(colors.white)
end
local function displayStatus(data)
local percent = math.floor((data.energy / maxEnergy) * 100)
monitor.setCursorPos(1, 2)
monitor.write("Autostart: ")
monitor.setTextColor(autostart and colors.lime or colors.red)
monitor.write(autostart and "An" or "Aus")
monitor.setTextColor(colors.white)
monitor.setCursorPos(1, 3)
monitor.write("Status: ")
monitor.setTextColor(data.active and colors.lime or colors.red)
monitor.write(data.active and "An" or "Aus")
monitor.setTextColor(colors.white)
monitor.setCursorPos(1, 4)
monitor.write("Brennstoff: " .. math.ceil(data.fuel))
monitor.setCursorPos(1, 5)
monitor.write("Fuel-Temp : " .. math.ceil(data.fuelHeat))
monitor.setCursorPos(1, 6)
monitor.write("CasingTemp: " .. math.ceil(data.casingHeat))
monitor.setCursorPos(1, 7)
monitor.write("RF/t : " .. math.ceil(data.rfPerTick))
monitor.setCursorPos(1, 8)
monitor.write("Energie : " .. percent .. "%")
end
local function handleAutostart(data)
if not autostart then return end
if data.energy < (maxEnergy * 0.4) then
reactor.setActive(true)
elseif data.energy > (maxEnergy * 0.9) then
reactor.setActive(false)
end
end
local function runMonitor()
while true do
clearScreen()
local data = getReactorData()
displayHeader()
displayStatus(data)
handleAutostart(data)
sleep(0.5)
end
end
local function handleTouch()
while true do
local event, side, x, y = os.pullEvent("monitor_touch")
if y == 2 then
autostart = not autostart
elseif y == 3 then
local currentState = reactor.getActive()
reactor.setActive(not currentState)
end
end
end
-- Start
parallel.waitForAny(runMonitor, handleTouch)
Comments
0 B
|👍
/👎
0 B
|0 👍
/0 👎
0 B
|👍
/👎