Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local cellSideBigReactor = "right"
- local cellSideSolar = "tile_thermalexpansion_cell_resonant_name_0"
- local statusChannelID = 5
- local reactorActivateP = 5
- local reactorTriggerP = 5
- -- Find Modem
- local modem = peripheral.find("modem", function(n, o) return o.isWireless() end)
- -- Find Reactor
- local reactor = peripheral.find("BigReactors-Reactor")
- if reactor == nil then
- error("Could not bind to reactor. Is one attached?")
- end
- -- Bind the Solar charged Energy Cell
- local solarCell = peripheral.wrap(cellSideSolar)
- if solarCell == nil then
- error("Could not bind to solar charged Energy Cell. Is one attached?")
- end
- term.clear()
- term.setCursorPos(1,1)
- print("BigReactor Monitor...")
- print()
- print("Reactor Output: Disabled")
- print("Reactor Status: Inactive")
- print("Reactor Buffer: ")
- print("Reactor Fuel: ")
- print("Reactor Generation: ")
- print("Solar Buffer: ")
- print()
- print("Press 'q' to quit.")
- print()
- rs.setOutput(cellSideBigReactor, false)
- local reactorEnabled = false
- reactor.setActive(false)
- local rActive = reactor.getActive()
- local pollTimer = os.startTimer(0)
- local status = {}
- while true do
- local event, p1, p2, p3, p4 = os.pullEvent()
- if event == "key" then
- if p1 == 16 then -- 'q'
- term.setCursorPos(1, 6)
- return
- end
- elseif event == "timer" and p1 == pollTimer then
- -- Check the Solar charged energy cell to determine if the
- -- reactor output should be enabled.
- local sEnergyP = (solarCell.getEnergyStored() / solarCell.getMaxEnergyStored()) * 100
- if sEnergyP <= reactorTriggerP then reactorEnabled = true end
- if sEnergyP >= 98 then reactorEnabled = false end
- rs.setOutput(cellSideBigReactor, reactorEnabled)
- local rEnergyP = (reactor.getEnergyStored() / 10000000) * 100
- if rActive == false and rEnergyP <= reactorActivateP then
- reactor.setActive(true)
- end
- if rActive == true and rEnergyP >= 98 then
- reactor.setActive(false)
- end
- if reactorEnabled == true then
- status["Reactor Output"] = "Enabled"
- else
- status["Reactor Output"] = "Disabled"
- end
- rActive = reactor.getActive()
- if rActive == true then
- status["Reactor Status"] = "Active"
- else
- status["Reactor Status"] = "Inactive"
- end
- term.setCursorPos(1,3)
- term.write("Reactor Output: " .. status["Reactor Output"] .. " ")
- term.setCursorPos(1,4)
- term.write("Reactor Status: " .. status["Reactor Status"] .. " ")
- status["Reactor Buffer"] = math.floor(rEnergyP) .. "%"
- status["Solar Buffer"] = math.floor(sEnergyP) .. "%"
- term.setCursorPos(1,5)
- term.write("Reactor Buffer: " .. status["Reactor Buffer"] .. " ")
- status["Reactor Fuel"] = math.floor((reactor.getFuelAmount() / reactor.getFuelAmountMax()) * 100) .. "%"
- term.setCursorPos(1,6)
- term.write("Reactor Fuel: " .. status["Reactor Fuel"] .. " ")
- status["Reactor Generation"] = math.floor(reactor.getEnergyProducedLastTick()) .. " RF/t"
- term.setCursorPos(1,7)
- term.write("Reactor Generation: " .. status["Reactor Generation"] .. " ")
- term.setCursorPos(1,8)
- term.write("Solar Buffer: " .. status["Solar Buffer"] .. " ")
- if modem ~= nil then modem.transmit(statusChannelID, 0, textutils.serialize(status)) end
- pollTimer = os.startTimer(5)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement