Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --cyteck
- --status monitor for Newcytek-Server-World
- local hw = {}
- local hwB = {}
- local hwD = {}
- local hwE = {}
- local reactor
- local storage
- --load API
- shell.run("delete caAPI")
- shell.run("pastebin get EDLdR1nF caAPI")
- os.loadAPI("caAPI")
- -- format number for print
- function format(num)
- out = tostring(math.floor(num)).." J"
- if num > 1000000000000 then
- num = num / 1000000000000
- out = tostring(math.floor(num)).." TJ"
- end
- if num > 1000000000 then
- num = num / 1000000000
- out = tostring(math.floor(num)).." GJ"
- end
- if num > 1000000 then
- num = num / 1000000
- out = tostring(math.floor(num)).." MJ"
- end
- if num > 1000 then
- num = num / 1000
- out = tostring(math.floor(num)).." KJ"
- end
- return out
- end
- --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
- --search mekanism maschine
- function searchB()
- local periList = peripheral.getNames()
- for i = 1, #periList do
- if peripheral.getType(periList[i]) == "mekanism_machine" then
- table.insert(hwD,periList[i])
- end
- end
- end
- --search Energy Cells
- function searchC()
- local periList = peripheral.getNames()
- for i = 1, #periList do
- if peripheral.getType(periList[i]) == "powered_tile" then
- table.insert(hwE,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(15,1)
- mon.setTextColor(colors.blue)
- num = #hw
- numB = #hwB
- mon.write("cytek Status Screen")
- 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
- for i = 1, #hwD do
- hwC = peripheral.wrap(hwD[i])
- nameC = hwC.getInventoryName()
- if nameC == "Induction Matrix" then
- storage = peripheral.wrap(hwD[i])
- end
- if nameC == "tile.Reactor.name.name" then
- reactorM = peripheral.wrap(hwD[i])
- end
- end
- storageN = storage.getInventoryName()
- reactorN = "Reactor"
- mon.setCursorPos(2,line)
- mon.setTextColor(colors.red)
- mon.write(storageN)
- mon.setTextColor(colors.green)
- maxE = storage.getMaxEnergyStored()
- isE = storage.getEnergyStored()
- input = storage.getInput()
- output = storage.getOutput()
- precent = math.floor(100 * isE / maxE)
- maxF = format(maxE)
- isF = format(isE)
- inF = format(input)
- outF = format(output)
- line = line + 1
- mon.setCursorPos(2,line)
- mon.write("Max:"..maxF)
- line = line + 1
- mon.setCursorPos(2,line)
- mon.write("Is: "..isF.." "..tostring(precent).."%")
- line = line + 1
- mon.setCursorPos(2,line)
- mon.write("In: "..inF)
- line = line + 1
- mon.setCursorPos(2,line)
- mon.write("Out:"..outF)
- line = line - 4
- mon.setCursorPos(25,line)
- mon.setTextColor(colors.red)
- mon.write(reactorN)
- mon.setTextColor(colors.green)
- maxR = reactorM.getMaxEnergyStored()
- isR = reactorM.getEnergyStored()
- precentR = math.floor(100 * isR / maxR)
- maxFR = format(maxR)
- isFR = format(isR)
- line = line + 1
- mon.setCursorPos(25,line)
- mon.write("Max:"..maxFR)
- line = line + 1
- mon.setCursorPos(25,line)
- mon.write("Is: "..isFR.." "..tostring(precentR).."%")
- line = line + 4
- mon.setCursorPos(2,line)
- mon.setTextColor(colors.red)
- num = #hwE
- mon.write("Energy Cell Status Screen Found "..num.." Cells")
- mon.setTextColor(colors.green)
- line = line + 1
- mon.setCursorPos(2,line)
- start_x = 2
- start_y = line
- for i = 1, #hwE do
- cell = peripheral.wrap(hwE[i])
- max = cell.getMaxEnergyStored()
- stored = cell.getEnergyStored()
- percent = math.floor(100 * stored / max)
- mon.setCursorPos(start_x,start_y)
- mon.write(tostring(i)..": "..tostring(percent).."%")
- start_x = start_x + 10
- if i == 5 then
- start_x = 2
- start_y = start_y + 2
- end
- if i == 10 then
- start_x = 2
- start_y = start_y + 2
- end
- end
- end
- end
- --prog start
- set_monitor()
- search()
- searchB()
- searchC()
- draw_screen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement