Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --BigReactor Info Status
- --automatic read and search in network
- local hw = {}
- local hwB = {}
- --load API
- shell.run("delete caAPI")
- shell.run("pastebin get EDLdR1nF caAPI")
- os.loadAPI("caAPI")
- --set monitor
- function set_monitor()
- local monitor_number = caAPI.get_hardware("monitor")
- local found = fs.exists("config/monitor.cfg")
- if found == true then
- file = fs.open("config/monitor.cfg","r")
- local fileData = {}
- local line = file.readLine()
- repeat
- table.insert(fileData,line)
- line = file.readLine()
- until line == nil
- file.close()
- monitor_number = fileData[1]
- end
- mon = peripheral.wrap(monitor_number)
- end
- --search reactores and turbines
- function search()
- local periList = peripheral.getNames()
- for i = 1, #periList do
- if peripheral.getType(periList[i]) == "BigReactors-Reactor" then
- table.insert(hw,periList[i])
- end
- end
- local periList = peripheral.getNames()
- for i = 1, #periList do
- if peripheral.getType(periList[i]) == "BigReactors-Turbine" then
- table.insert(hwB,periList[i])
- end
- end
- end
- --draw screen
- function draw_screen()
- xi = true
- while xi == true do
- sleep(1)
- mon.setTextColor(1)
- mon.setBackgroundColor(colors.black)
- mon.clear()
- mon.setCursorPos(2,1)
- mon.setTextColor(colors.blue)
- num = #hw
- numB = #hwB
- mon.write("Reactor Status Screen")
- mon.setCursorPos(2,2)
- mon.write("Found "..num.." Reactors "..numB.." Turbines")
- line = 3
- for i = 1, #hw do
- mon.setCursorPos(2,line)
- mon.setTextColor(colors.red)
- mon.write("Reactor Port:"..hw[i])
- mon.setTextColor(colors.green)
- reactor = peripheral.wrap(hw[i])
- line = line + 1
- mon.setCursorPos(2,line)
- mon.write("Active:")
- mon.write(reactor.getActive())
- mon.write(" Rod:")
- mon.write(reactor.getControlRodLevel(0),"%")
- mon.write("%")
- line = line + 1
- mon.setCursorPos(2,line)
- mon.write("RF/T: ")
- mon.write(math.floor(reactor.getEnergyProducedLastTick()))
- mon.write(" RF Stored: ")
- mon.write(math.floor(reactor.getEnergyStored()))
- if math.floor(reactor.getEnergyStored()) > 9500000 then
- reactor.setAllControlRodLevels(100)
- end
- if math.floor(reactor.getEnergyStored()) < 5000000 then
- reactor.setAllControlRodLevels(0)
- end
- line = line + 1
- mon.setCursorPos(2,line)
- mon.write("Casing Heat: ")
- mon.write(math.floor(reactor.getCasingTemperature()))
- mon.write(" Fuel Heat: ")
- mon.write(math.floor(reactor.getFuelTemperature()))
- line = line + 2
- end
- for i = 1, #hwB do
- mon.setCursorPos(2,line)
- mon.setTextColor(colors.red)
- mon.write("Reactor Port:"..hwB[i])
- mon.setTextColor(colors.green)
- turbine = peripheral.wrap(hwB[i])
- line = line + 1
- mon.setCursorPos(2,line)
- mon.write("Active:")
- mon.write(turbine.getActive())
- line = line + 1
- mon.setCursorPos(2,line)
- mon.write("RF/T: ")
- mon.write(math.floor(turbine.getEnergyProducedLastTick()))
- mon.write(" RF Stored: ")
- mon.write(math.floor(turbine.getEnergyStored()))
- line = line + 2
- end
- end
- end
- --prog start
- set_monitor()
- search()
- draw_screen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement