-- -- Remote monitor component for reactor control program -- -- Author: VirtualDXS -- -- History: -- v0.1, 2021-09-03 -- First version threshold = 0.6 mon = peripheral.wrap("monitor_1") cells = { peripheral.wrap("thermal:energy_cell_1"), peripheral.wrap("thermal:energy_cell_2"), peripheral.wrap("thermal:energy_cell_3"), peripheral.wrap("thermal:energy_cell_4") } function writeMonStatus (state,fraction) local pct = math.floor(fraction*10000)/100 mon.clear() if mon.setTextScale ~= nil then mon.setTextScale(1) local width, height = mon.getSize() if width < 15 or height < 5 then -- Small monitor - scale down mon.setTextScale(0.5) else -- Large monitor - scale up local scale = math.min(width / 14, height / 2, 5) scale = math.floor(scale * 2) / 2 -- multiple of 0.5 mon.setTextScale(scale) end end mon.setCursorPos(1,1) mon.write("State: " .. (state and "On" or "Off")) mon.setCursorPos(1,2) mon.write("Energy: " .. pct .. "%") end while true do local energyCur = 0 local energyMax = 0 for _,cell in pairs(cells) do energyCur = energyCur + cell.getEnergy() energyMax = energyMax + cell.getEnergyCapacity() end local energyFraction = energyCur/energyMax print(energyFraction) local state = energyFraction < threshold redstone.setOutput("left",state) writeMonStatus(state,energyFraction) sleep(10) end