Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local onLevel = .20
- local offLevel = .70
- local usingInduction = false
- local updateRate = .5
- local reactor = peripheral.find("BiggerReactors_Reactor")
- local m = peripheral.find("monitor")
- local powerBank = peripheral.find("Induction Matrix")
- local x,y = m.getSize()
- local numbars = 0
- local p = 0
- local level = 0
- local lastLevel = 0
- local change = 0
- local defaultMax = reactor.battery().capacity()
- local numRods = reactor.controlRodCount()
- local controlLevel = reactor.getControlRod(0).level()
- local maxFuelTemp = 5000
- local maxCasingTemp = 5000
- m.setTextScale(1)
- local maxPower = 0
- if usingInduction and powerBank then
- maxPower = powerBank.getMaxEnergy() * .4
- else
- maxPower = defaultMax
- end
- function getPowerUsage()
- return math.floor(reactor.battery().producedLastTick() - change)
- end
- function checkValue()
- if controlLevel > 100 then
- controlLevel = 100
- elseif controlLevel < 0 then
- controlLevel = 0
- end
- end
- function checkFiles()
- if not fs.exists("startup") then
- startFile = fs.open("startup", "w")
- startFile.write("multishell.launch({}, \"reactor\")")
- startFile.close()
- end
- if not fs.exists("update") then
- shell.run("pastebin","get","zbwpL7G7","update")
- end
- end
- function center(s)
- cx,cy = term.getCursorPos()
- term.setCursorPos((x/2) - (string.len(s)/2),cy)
- print(s)
- end
- function formatNumber(num)
- if num > 1000000000 then
- num = round(num/1000000000) .. "G"
- elseif num > 1000000 then
- num = round(num/1000000) .. "M"
- elseif num > 1000 then
- num = round(num/1000) .. "K"
- end
- return num
- end
- function round(num)
- return math.floor(num*1000) / 1000
- end
- checkFiles()
- while true do
- if usingInduction then
- level = powerBank.getEnergy() *.4
- else
- level = reactor.battery().stored()
- end
- x,y = m.getSize()
- if level/maxPower < onLevel then
- reactor.setActive(true)
- end
- if level/maxPower > offLevel then
- reactor.setActive(false)
- end
- term.clear()
- term.setCursorPos(1,1)
- print("Current Level - " .. formatNumber(level))
- print("Current Level Raw- " .. level)
- print("Powered = " .. tostring(reactor.active()))
- print("Number of Control Rods - " .. numRods)
- print("\nHit Q to reboot Program.\nHit U to update.")
- print("Program written by RedStoner_Pro")
- timer = os.startTimer(updateRate)
- computer = term.redirect(m)
- term.clear()
- term.setCursorPos(1,1)
- center("Reactor Manager Monitor")
- -- Power Bar
- p = level/maxPower
- numBars = math.floor((x-4)*p)
- print("Energy")
- term.write(" |")
- term.setBackgroundColor(colors.red)
- if p > offLevel then
- term.setBackgroundColor(colors.green)
- elseif p > onLevel then
- term.setBackgroundColor(colors.yellow)
- end
- for i=1,numBars do
- term.write(" ")
- end
- term.setBackgroundColor(colors.black)
- cx,cy= term.getCursorPos()
- term.setCursorPos(x-1,cy)
- print("|")
- sLevel = formatNumber(level) .. " / ".. formatNumber(maxPower)
- center(sLevel)
- -- Fuel
- fP = reactor.fuelTank().fuel()/reactor.fuelTank().capacity()
- numFBars = math.floor((x-4)*fP)
- print("Fuel Amount")
- term.write(" |")
- term.setBackgroundColor(colors.yellow)
- for i=1,numFBars do
- term.write(" ")
- end
- term.setBackgroundColor(colors.black)
- cx,cy= term.getCursorPos()
- term.setCursorPos(x-1,cy)
- print("|")
- center(math.floor(reactor.fuelTank().fuel()) .. "/" .. math.floor(reactor.fuelTank().capacity()) )
- -- Case Temp
- caseTemp = reactor.casingTemperature()
- caseP = caseTemp/maxCasingTemp
- numCaseBars = math.floor((x-4)*caseP)
- print("Case Temperature")
- term.write(" |")
- if caseTemp > maxCasingTemp * .666 then
- term.setBackgroundColor(colors.red)
- elseif caseTemp > maxCasingTemp * .333 then
- term.setBackgroundColor(colors.green)
- else
- term.setBackgroundColor(colors.blue)
- end
- for i=1,numCaseBars do
- term.write(" ")
- end
- term.setBackgroundColor(colors.black)
- cx,cy= term.getCursorPos()
- term.setCursorPos(x-1,cy)
- print("|")
- center(math.floor(caseTemp) .. " Celcius")
- --Fuel Temp
- fuelTemp = reactor.fuelTemperature()
- fuelP = fuelTemp/maxFuelTemp
- numFuelBars = math.floor((x-4)*fuelP)
- print("Fuel Temperature")
- term.write(" |")
- if fuelTemp > maxFuelTemp * .666 then
- term.setBackgroundColor(colors.red)
- elseif fuelTemp > maxFuelTemp * .333 then
- term.setBackgroundColor(colors.green)
- else
- term.setBackgroundColor(colors.blue)
- end
- for i=1,numFuelBars do
- term.write(" ")
- end
- term.setBackgroundColor(colors.black)
- cx,cy= term.getCursorPos()
- term.setCursorPos(x-1,cy)
- print("|")
- center(math.floor(fuelTemp) .. " Celcius")
- -- Stats
- change = math.floor((level - lastLevel)/(20 * updateRate))
- print("Fuel Usage = " .. reactor.fuelTank().burnedLastTick() .. " mB/t")
- print("RF/T Created = " .. math.floor(reactor.battery().producedLastTick()))
- print("RF/T Used = " .. getPowerUsage())
- print("RF/T Internal Change = " .. change)
- -- Control Rod Modifiers
- term.setCursorPos(1,y-1)
- center("Control Rod Level = " .. controlLevel)
- term.setBackgroundColor(colors.red)
- term.setCursorPos(2,y)
- term.write(" -1 ")
- term.setCursorPos(7,y)
- term.write(" -10 ")
- term.setCursorPos((x/2-1),y)
- if reactor.active() then
- term.setBackgroundColor(colors.green)
- else
- term.setBackgroundColor(colors.red)
- end
- term.write("POWER")
- term.setBackgroundColor(colors.green)
- term.setCursorPos(x-4,y)
- term.write(" +1 ")
- term.setCursorPos(x-10,y)
- term.write(" +10 ")
- term.setBackgroundColor(colors.black)
- lastLevel = level
- term.redirect(computer)
- e = "nottimer"
- while e ~= "timer" do
- e,p1,p2,p3 = os.pullEvent()
- if e == "timer" then
- break
- elseif e == "key" and p1 == 16 then
- os.reboot()
- break
- elseif e == "key" and p1 == 22 then
- shell.run("update")
- elseif e == "monitor_touch" then
- if p3 == y then
- if p2 >= 2 and p2 <= 5 then
- controlLevel = controlLevel - 1
- checkValue()
- reactor.setAllControlRodLevels(controlLevel)
- elseif p2 >= 7 and p2 <= 11 then
- controlLevel = controlLevel - 10
- checkValue()
- reactor.setAllControlRodLevels(controlLevel)
- elseif p2 >= x-10 and p2 <= x-6 then
- controlLevel = controlLevel + 10
- checkValue()
- reactor.setAllControlRodLevels(controlLevel)
- elseif p2 >= x-4 and p2 <= x-1 then
- controlLevel = controlLevel + 1
- checkValue()
- reactor.setAllControlRodLevels(controlLevel)
- elseif p2 >= x/2-1 and p2 <= x/2+3 then
- if reactor.active() then
- reactor.setActive(false)
- else
- reactor.setActive(true)
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment