Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Cosmetic settings for the monitor
- local textScale = 1.5 --Size of text
- local tempDecimals = 3 --Decimal places to show for temperature
- local fuelDecimals = 3 --Decimal places to show for fuel usage
- -- Settings for dealing with an overheating reactor
- local maxTemperature = 1500
- local tempWarningRatio = 0.75 --Ratio to change color for temp
- local failsafeMaxDraw = 20 --Max Percentage Draw
- local failsafeCooldown = 150 --Timer in Seconds
- local safeTemp = 1 --Temperature to resume normal operation at
- -- Increases cooldown timer if reactor stays above max temp, and
- -- goes to 0 draw if timer reaches double failsafeCooldown
- local handleBadSettings = true
- -- Use sides or modem names to connect the devices
- local monitorName = "top"
- local reactorName = "BigReactors-Reactor_0"
- -- How long to wait before trying to connect if parts aren't ready
- -- Recommended values are 1 if next to computer, 5 if using modem.
- local monitorWait = 1
- local reactorWait = 1
- --The first half of the warning messages
- local problemNotice = "OH NO!"
- local workingNotice = "AW YEAH!"
- local failsafeNotice = "TOO MUCH!"
- --The string of characters (if any) that separates the two halves
- --of the warning messages
- local noticeSeparator = " - "
- --The second half of the warning messages
- local offlineWarning = "Winging It"
- local emptyWarning = "Zero Stamina"
- local noDrawWarning = "Heavy Petting"
- local lightDrawWarning = "Light Penetration"
- local mediumDrawWarning = "Decent Penetration"
- local highDrawWarning = "BALLS DEEP!"
- local overheatWarning = "Need A Rest!"
- --Used Internally - changing will do nothing
- local rodLevels = 0
- local currentWarning = ""
- local cooldownTimer = 0
- local warningColor = colors.white
- local emptyflag = 0
- local offlineflag = 0
- local flashflag = 0
- local overheated = false
- local monitor = nil
- local reactor = nil
- while reactor == nil do
- reactor=peripheral.wrap(reactorName)
- if reactor == nil then
- print("Waiting for reactor peripheral")
- os.sleep(reactorWait)
- end
- end
- print("Found reactor. Looking for monitor.")
- while monitor == nil do
- monitor = peripheral.wrap(monitorName)
- if monitor == nil then
- print("Waiting for monitor to connect")
- os.sleep(monitorWait)
- end
- end
- print("Monitor found.")
- while not reactor.getConnected() do
- print("Waiting for reactor to connect.")
- os.sleep(reactorWait)
- end
- print("Program Initialized - View Monitor.")
- monitor.setTextScale(textScale)
- monitor.setBackgroundColor(colors.black)
- function round(num, idp)
- local mult = 10^(idp or 0)
- return math.floor(num * mult + 0.5) / mult
- end
- while true do
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.setTextColor(colors.orange)
- monitor.write('Program has been initialized')
- monitor.setCursorPos(1,2)
- monitor.setTextColor(colors.white)
- monitor.write('Fuel Level - ')
- monitor.setTextColor(colors.yellow)
- monitor.write(math.floor(((reactor.getFuelAmount()/reactor.getFuelAmountMax())*100)+0.5)..'% Fuel')
- monitor.setCursorPos(1,3)
- monitor.setTextColor(colors.white)
- monitor.write('Waste Level - ')
- monitor.setTextColor(colors.lightBlue)
- monitor.write(math.floor(((reactor.getWasteAmount()/reactor.getFuelAmountMax())*100)+0.5)..'% Waste')
- monitor.setCursorPos(1,5)
- monitor.setTextColor(colors.white)
- monitor.write('Control Rod Levels - ')
- monitor.setTextColor(colors.green)
- monitor.setCursorPos(1,6)
- monitor.write('Rod 1: '..(100-(reactor.getControlRodLevel(0)))..'% Thrust')
- monitor.setCursorPos(25,6)
- monitor.write('Rod 2: '..(100-(reactor.getControlRodLevel(1)))..'% Thrust')
- monitor.setCursorPos(1,7)
- monitor.write('Rod 3: '..(100-(reactor.getControlRodLevel(2)))..'% Thrust')
- monitor.setCursorPos(25,7)
- monitor.write('Rod 4: '..(100-(reactor.getControlRodLevel(3)))..'% Thrust')
- monitor.setCursorPos(1,8)
- monitor.write('Rod 5: '..(100-(reactor.getControlRodLevel(4)))..'% Thrust')
- monitor.setCursorPos(25,8)
- monitor.write('Rod 6: '..(100-(reactor.getControlRodLevel(5)))..'% Thrust')
- monitor.setCursorPos(1,9)
- monitor.write('Rod 7: '..(100-(reactor.getControlRodLevel(6)))..'% Thrust')
- monitor.setCursorPos(25,9)
- monitor.write('Rod 8: '..(100-(reactor.getControlRodLevel(7)))..'% Thrust')
- monitor.setCursorPos(1,10)
- monitor.write('Rod 9: '..(100-(reactor.getControlRodLevel(8)))..'% Thrust')
- monitor.setCursorPos(25,10)
- monitor.write('Rod 10: '..(100-(reactor.getControlRodLevel(9)))..'% Thrust')
- monitor.setCursorPos(1,11)
- monitor.write('Rod 11: '..(100-(reactor.getControlRodLevel(10)))..'% Thrust')
- monitor.setCursorPos(25,11)
- monitor.write('Rod 12: '..(100-(reactor.getControlRodLevel(11)))..'% Thrust')
- monitor.setCursorPos(1,12)
- monitor.write('Rod 13: '..(100-(reactor.getControlRodLevel(12)))..'% Thrust')
- monitor.setCursorPos(25,12)
- monitor.write('Rod 14: '..(100-(reactor.getControlRodLevel(13)))..'% Thrust')
- monitor.setCursorPos(1,13)
- monitor.write('Rod 15: '..(100-(reactor.getControlRodLevel(14)))..'% Thrust')
- monitor.setCursorPos(25,13)
- monitor.write('+10 more...')
- monitor.setCursorPos(1,15)
- monitor.setTextColor(colors.white)
- monitor.write('Temperature')
- monitor.setCursorPos(25,15)
- monitor.write("Fuel Usage")
- monitor.setCursorPos(1,16)
- if reactor.getFuelTemperature()>=(maxTemperature*tempWarningRatio) then
- monitor.setTextColor(colors.purple)
- elseif reactor.getFuelTemperature()>=maxTemperature then
- monitor.setTextColor(colors.red)
- else
- monitor.setTextColor(colors.green)
- end
- monitor.write(round(reactor.getFuelTemperature(), tempDecimals)..'C')
- monitor.setCursorPos(25,16)
- monitor.write(round(reactor.getFuelConsumedLastTick(), fuelDecimals)..'mB')
- monitor.setCursorPos(1,18)
- monitor.setTextColor(colors.white)
- monitor.write('Flux')
- monitor.setCursorPos(1,19)
- monitor.setTextColor(colors.green)
- monitor.write(reactor.getEnergyStored()..' RF Stored ')
- if reactor.getEnergyProducedLastTick()>=500 and reactor.getEnergyProducedLastTick()<2000 then
- monitor.setTextColor(colors.orange)
- end
- if reactor.getEnergyProducedLastTick()>=2000 then
- monitor.setTextColor(colors.red)
- end
- monitor.write((math.floor(reactor.getEnergyProducedLastTick()+0.5))..'RF/t')
- monitor.setCursorPos(1,21)
- monitor.setTextColor(colors.orange)
- monitor.write('Warnings:')
- if flashflag==0 then
- flashflag=1
- currentWarning = ""
- if offlineflag==1 then
- warningColor = colors.lightGray
- currentWarning = problemNotice..noticeSeparator..offlineWarning
- elseif emptyflag==1 then
- warningColor = colors.pink
- currentWarning = problemNotice..noticeSeparator..emptyWarning
- elseif cooldownTimer > 0 then
- currentWarning = failsafeNotice..noticeSeparator
- if overheated then
- warningColor = colors.green
- currentWarning = currentWarning..overheatWarning..' ('..cooldownTimer..')'
- end
- else
- currentWarning = workingNotice..noticeSeparator
- end
- if emptyflag==0 and offlineflag==0 and not overheated then
- if reactor.getControlRodLevel(0)>99 then
- warningColor = colors.lightBlue
- currentWarning = currentWarning..noDrawWarning
- elseif reactor.getControlRodLevel(0)>75 then
- warningColor = colors.yellow
- currentWarning = currentWarning..lightDrawWarning
- elseif reactor.getControlRodLevel(0)>50 then
- warningColor = colors.orange
- currentWarning = currentWarning..mediumDrawWarning
- else
- warningColor = colors.red
- currentWarning = currentWarning..highDrawWarning
- end
- if cooldownTimer > 0 then
- warningColor = colors.green
- currentWarning = currentWarning..' ('..cooldownTimer..')'
- end
- end
- monitor.setCursorPos(1,22)
- monitor.setTextColor(warningColor)
- monitor.write(currentWarning)
- else
- flashflag=0
- monitor.setCursorPos(1,22)
- monitor.clearLine()
- end
- if emptyflag==0 and offlineflag==0 and not overheated then
- if reactor.getFuelTemperature() > maxTemperature and cooldownTimer == 0 then
- cooldownTimer = failsafeCooldown
- elseif reactor.getFuelTemperature() > maxTemperature and handleBadSettings then
- cooldownTimer = cooldownTimer + 1
- if cooldownTimer == failsafeCooldown * 2 then
- overheated = true
- end
- end
- if reactor.getEnergyStored()>= 1 then
- rodLevels = math.floor(reactor.getEnergyStored()/100000)
- else
- rodLevels = 0 --Full Draw
- end
- if cooldownTimer > 0 and rodLevels < (100 - failsafeMaxDraw) then
- rodLevels = (100 - failsafeMaxDraw)
- end
- reactor.setAllControlRodLevels(rodLevels)
- end
- if overheated then
- reactor.setAllControlRodLevels(100)
- end
- if reactor.getFuelAmount()<=100 and offlineflag==0 then
- reactor.setAllControlRodLevels(100)
- reactor.setActive(false)
- emptyflag=1
- else
- emptyflag=0
- end
- if rs.getInput('top')==false and emptyflag==0 then
- reactor.setActive(true)
- offlineflag=0
- end
- if rs.getInput('top')==true and emptyflag==0 then
- reactor.setActive(false)
- reactor.setAllControlRodLevels(100)
- offlineflag=1
- end
- if cooldownTimer > 0 and reactor.getFuelTemperature() <= maxTemperature then
- cooldownTimer = cooldownTimer - 1
- if overheated and (cooldownTimer == 0 or reactor.getFuelTemperature() == 0) then
- overheated = false
- cooldownTimer = 0
- end
- end
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement