Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Power Station Controller and Monitor
- -- Test script by ccraftersanonmoose
- ----------------------------------------
- -- Version History
- -- Version 0.1 - 2/5/23
- -- added buttons to activate and scram reactor
- -- Version 0.2 2/13/23
- -- added monitoring of actual burn rate and temp
- -- adjusted temp to show absolute number in celsius
- -- would like to add buttons to increment and decrement the burn rate
- -- version 0.2.2 2/16/23
- -- added status monitoring
- -- added set burn rate monitoring
- -- added buttons for burn rate
- -- version 0.3 3/7/2023
- -- adding monitoring of SPS and battery bank
- -- would like button to turn SPS on and off
- ----------------------------------------
- os.loadAPI("button")
- mon = peripheral.find("monitor")
- reactor = peripheral.find("fissionReactorLogicAdapter")
- sps = peripheral.find("spsPort")
- mon.clear()
- function fillTable()
- -- Reactor Section
- button.setTable("Acivate", activateReactor, 1,11,5,7)
- button.setTable("SCRAM", scramReactor, 1,11,9,11)
- button.setTable("+", incrementBurnRate, 5,6,13,14)
- button.setTable("-", decrementBurnRate, 8,9,13,14)
- -- SPS Section
- button.setTable("On", spsOn, 13,15,5,7)
- button.setTable("Off", spsOff, 17,19,5,7)
- button.screen()
- end
- function getClick()
- event,side,x,y = os.pullEvent("monitor_touch")
- button.checkxy(x,y)
- end
- function activateReactor()
- button.flash("Activate")
- reactor.activate()
- end
- function scramReactor()
- button.flash("SCRAM")
- reactor.scram()
- end
- function incrementBurnRate()
- button.flash("+")
- reactor.setBurnRate(reactor.getBurnRate() + 1)
- end
- function decrementBurnRate()
- button.flash("+")
- reactor.setBurnRate(reactor.getBurnRate() - 1)
- end
- --function getInfo()
- --reactor.getActualBurnRate()
- --reactor.getCoolantFilledPercentage()
- --reactor.getFuelFilledPercentage()
- --reactor.getTemperature()
- --reactor.getStatus()
- --end
- function spsOn()
- button.flash("+")
- sps.setMode(true)
- end
- function spsOff()
- button.flash("+")
- sps.setMode(false)
- end
- function displayInfo()
- mon.setTextScale(1)
- -- Reactor Section
- mon.setCursorPos(1,2)
- mon.write("Reactor")
- if reactor.getStatus() == true then
- mon.setCursorPos(1,3)
- mon.write("Status:")
- mon.setCursorPos(1,4)
- -- mon.clearLine()
- mon.write("Active ")
- else
- mon.setCursorPos(1,3)
- mon.write("Status:")
- mon.setCursorPos(1,4)
- -- mon.clearLine()
- mon.write("Disabled")
- end
- mon.setCursorPos(1,12)
- mon.write("Burn Rate")
- mon.setCursorPos(1,13)
- mon.write(reactor.getBurnRate())
- -- mon.setCursorPos(1,8)
- -- mon.write("Current Burn Rate: ")
- -- mon.setCursorPos(1,10)
- -- mon.write(reactor.getActualBurnRate())
- mon.setCursorPos(1,16)
- mon.write("Current Temp:")
- mon.setCursorPos(1,17)
- mon.write(math.floor(reactor.getTemperature() - 273.15).."C ")
- -- SPS Section
- mon.setCursorPos(13,2)
- mon.write("SPS")
- mon.setCursorPos(13,3)
- mon.write("Status:")
- if sps.getMode() == true then
- mon.setCursorPos(13,4)
- mon.write("Active ")
- else
- mon.setCursorPos(13,4)
- -- mon.clearLine()
- mon.write("Disabled")
- end
- end
- fillTable()
- button.heading("Power Station")
- while true do
- displayInfo()
- getClick()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement