Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --extreme reactors reactor needed
- --draconic star needed for power storage
- --gui api
- local mon = peripheral.wrap("top")
- local monX, monY = mon.getSize()
- function clear()
- mon.clear()
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(1,1)
- mon.setTextColor(colors.white)
- end
- function drawText(x, y, text, color_txt, color_bg)
- mon.setBackgroundColor(color_bg)
- mon.setTextColor(color_txt)
- mon.setCursorPos(x,y)
- mon.write(text)
- end
- function drawLine(x, y, length, size, color_bar)
- for yPos = y, y+size-1 do
- mon.setBackgroundColor(color_bar)
- mon.setCursorPos(x, yPos)
- mon.write(string.rep(" ", length))
- end
- end
- function drawProg(x, y, name, length, size, minVal, maxVal, color_bar, color_bg)
- drawLine(x, y, length, size, color_bg)
- local barSize = math.floor((minVal/maxVal)*length)
- drawLine(x, y, barSize, size, color_bar)
- local text = name.." "..math.floor((minVal/maxVal)*100).."%"
- if barSize > monX/2+#text/2 then
- drawText(monX/2-#text/2, y+size/2, text, colors.black, color_bar)
- elseif barSize > #text/2 then
- drawText((x+barSize)-#text, y+size/2, text, colors.black, color_bar)
- end
- end
- -- main code
- local reactor = peripheral.find("BigReactors-Reactor")
- local star = peripheral.find("draconic_rf_storage")
- local teir = 7
- local starCurr = star.getEnergyStored()
- local starMax = star.getMaxEnergyStored()
- local starPercent = math.floor((starCurr/starMax)*100)
- local starTrans = star.getTransferPerTick()
- local version = "1.0"
- local reactorPwr = reactor.getActive()
- local reactorStatus = "nominal"
- local reactorWaste = reactor.getWasteAmount()
- local reactorFuel = reactor.getFuelAmountMax()
- local reactorWastePercent = math.floor((reactorWaste/reactorFuel)*100)
- if starMax == 45500000 then
- teir = "1"
- elseif starMax == 273000000 then
- teir = "2"
- elseif starMax == 1640000000 then
- teir = "3"
- elseif starMax == 9880000000 then
- teir = "4"
- elseif starMax == 59300000000 then
- teir = "5"
- elseif starMax == 356000000000 then
- teir = "6"
- elseif starMax == 2140000000000 then
- teir = "7"
- elseif starMax > 2140000000000 then
- teir = "8"
- else
- error() "no valid star found"
- end
- function mainScreen()
- drawLine(2, 2, monX-2, 1, colors.gray)
- for i = 3, 25 do
- drawLine(2, i, 1, 1, colors.gray)
- end
- drawLine(2, 25, monX-2, 1, colors.gray)
- for i = 3, 25 do
- drawLine(70, i, 1, 1, colors.gray)
- end
- for i = 3, 25 do
- drawLine(35, i, 1, 1, colors.gray)
- end
- drawText(10, 4, "Reactor_status", colors.yellow, colors.black)
- drawText(44, 4, "Draconic_Star_status", colors.yellow, colors.black)
- drawText(11, 1, "Power Monitoring System. ver: "..version.." - by: tib tib", colors.green, colors.black)
- drawText(37, 8, "Current Teir: "..teir, colors.yellow, colors.black)
- drawText(37 , 9, "Current Transfer: ", colors.yellow, colors.black)
- drawText(37, 10, "Current Stored: ", colors.yellow, colors.black)
- drawText(37, 11, "Maximum Storage: "..starMax, colors.white, colors.black)
- drawLine(2, 5, monX-2, 1, colors.gray)
- drawText(4, 8, "Reactor: ", colors.yellow, colors.black)
- drawText(4, 10, "status: ", colors.yellow, colors.black)
- drawText(4, 12, "wasteLevel: ", colors.yellow, colors.black)
- end
- function startup()
- clear()
- sleep(1)
- mon.write("Hello, and thank you for choosing Power Management systems by Tibbers")
- sleep(1)
- mon.setCursorPos(1,3)
- mon.write("now detecting all dependencies")
- mon.setCursorPos(1,5)
- sleep(1)
- mon.write("reactor found!!")
- mon.setCursorPos(1,7)
- sleep(1)
- mon.write("energy core found")
- mon.setCursorPos(1,9)
- sleep(1)
- mon.write("all dependencies found... now booting...")
- mon.setCursorPos(1,11)
- sleep(1)
- sleep(.5)
- clear()
- mon.setBackgroundColor(colors.black)
- sleep(1)
- end
- function Loop()
- while true do
- starTrans = star.getTransferPerTick()
- starPercent = math.floor((starCurr/starMax)*100)
- sleep(.1)
- end
- end
- function Status()
- while true do
- starTrans = star.getTransferPerTick()
- starPercent = math.floor((starCurr/starMax)*100)
- reactorPwr = reactor.getActive()
- reactorWastePercent = math.floor((reactorWaste/reactorFuel)*100)
- reactorWaste = reactor.getWasteAmount()
- reactorFuel = reactor.getFuelAmountMax()
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(56,9)
- mon.write(" ")
- mon.setCursorPos(56,9)
- if starTrans > 0 then
- mon.setTextColor(colors.green)
- mon.write(starTrans)
- elseif starTrans < 0 then
- mon.setTextColor(colors.red)
- mon.write(starTrans)
- else
- mon.setTextColor(colors.yellow)
- mon.write(starTrans)
- end
- mon.setCursorPos(55,10)
- mon.write(" ")
- mon.setCursorPos(55,10)
- mon.setTextColor(colors.blue)
- mon.write(starPercent.."%")
- drawProg( 37, 12, " ", 30, 1, starPercent, 100, colors.blue, colors.white)
- if reactorPwr == true then
- mon.setCursorPos(14,8)
- mon.setTextColor(colors.green)
- mon.setBackgroundColor(colors.black)
- mon.write(" ")
- mon.setCursorPos(14,8)
- mon.write("online")
- else
- mon.setCursorPos(14,8)
- mon.setTextColor(colors.red)
- mon.setBackgroundColor(colors.black)
- mon.write(" ")
- mon.setCursorPos(14,8)
- mon.write("offline")
- end
- if reactorPwr == true and reactorWastePercent < 5 then
- reactorStatus = "nominal"
- elseif reactorPwr == true and reactorWastePercent >= 5 then
- reactorStatus = "Waste Eject Error"
- elseif reactorPwr == false and reactorWastePercent < 5 then
- reactorStatus = "Manual Shutdown"
- elseif reactorPwr == false and reactorWastePercent >= 5 then
- reactorStatus = "multiple Failures"
- else
- error() "not valid peramiter"
- end
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.pink)
- mon.setCursorPos(13,10)
- mon.write(" ")
- mon.setCursorPos(13,10)
- mon.write(reactorStatus)
- mon.setCursorPos(16,12)
- mon.setTextColor(colors.orange)
- mon.write(" ")
- mon.setCursorPos(16,12)
- mon.write(reactorWastePercent.."%")
- sleep(.1)
- end
- end
- startup()
- clear()
- mainScreen()
- Status()
Advertisement
Add Comment
Please, Sign In to add comment