Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- CHANGE THIS BASED ON MONITOR LOCATION
- local monitorLoc = "left"
- -- PASSIVE COOLED REACTOR
- -- DETERMINES ACTIVATION AND CUTOFF PERCENT
- local activatePercent = 90.00
- local cutoffPercent = 99.20
- -- ACTIVE COOLED REACTOR
- -- DETERMINES ACTIVATION AND CUTOFF TEMPERATURE
- local cutoffTemp = 6000.00
- local activateTemp = 800.00
- -- REACTOR AND MONITOR VARIABLE
- local reactor
- local monitor
- -- Reactor Vars
- -- DO NOT MODIFY
- local isActiveCooled
- local isActive
- local controlRods
- local energyStored
- local percentFull
- local fuelTemp
- local caseTemp
- local fuelAmount
- local wasteAmount
- local fuelMax
- local fuelPercent
- local energyProduced
- local hotFluidProduced
- local hotFluidStored
- local coolantStored
- local compStart = false
- -- getDevices(device): Get device specified by parameter (reactor, monitor)
- function getDevices(device)
- local perList = peripheral.getNames()
- device = device:lower()
- for perIndex = 1, #perList do
- if (string.lower(peripheral.getType(perList[perIndex])) == device) then
- return peripheral.wrap(perList[perIndex])
- end --if statement
- end --for perIndex = 1
- end --getDevices
- function write(message, clear, line, col, color)
- if (line == nil) and (col == nil) and (color == nil) then
- --clearLine(clear)
- monitor.write(message)
- else if (color == nil) then
- monitor.setCursorPos(col, line)
- clearLine(clear)
- monitor.write(message)
- else
- if (line ~= 0) and (col ~= 0) then
- monitor.setCursorPos(col, line)
- clearLine(clear)
- end
- monitor.setTextColor(color)
- monitor.write(message)
- monitor.setTextColor(colors.white)
- end
- end
- end
- function clearLine(clear)
- if clear then
- monitor.clearLine()
- end
- end
- function roundOne(num)
- return math.floor(num * 10) * 0.1
- end
- function roundTwo(num)
- return math.floor(num * 100) * 0.01
- end
- --sleep(5)
- reactor = getDevices("BigReactors-Reactor")
- monitor = peripheral.wrap(monitorLoc)
- monitor.setTextScale(1)
- monitor.clear()
- monitor.setCursorPos(1,1)
- -- Setting text to RED and writing intro
- write("Reactor Analisys System", true, 1, 1, colors.red)
- -- Drawing line across screen
- monitor.setCursorPos(1,2)
- clearLine(true)
- for i = 1, 60 do
- write("-", false, 2, i, colors.blue)
- end
- function queryReactor()
- isActiveCooled = reactor.isActivelyCooled();
- isActive = reactor.getActive()
- controlRods = reactor.getNumberOfControlRods()
- fuelTemp = roundOne(reactor.getFuelTemperature())
- caseTemp = roundOne(reactor.getCasingTemperature())
- fuelAmount = math.floor(reactor.getFuelAmount())
- fuelMax = math.floor(reactor.getFuelAmountMax())
- fuelPercent = roundTwo((fuelAmount / fuelMax) * 100)
- wasteAmount = math.floor(reactor.getWasteAmount())
- if isActiveCooled then
- hotFluidStored = reactor.getHotFluidAmount()
- coolantStored = reactor.getCoolantAmount()
- hotFluidProduced = reactor.getHotFluidProducedLastTick()
- else
- energyStored = math.floor(reactor.getEnergyStored())
- percentFull = roundTwo((energyStored / 10000000.0) * 100)
- energyProduced = roundTwo(reactor.getEnergyProducedLastTick())
- end
- if isActiveCooled then
- if (isActive == false) and (caseTemp < activateTemp) then
- reactor.setActive(true)
- compStart = true
- end
- if (isActive == true) and (compStart == true) and (caseTemp >= cutoffTemp) then
- reactor.setActive(false)
- compStart = false
- end
- end
- end
- function statusLoop()
- -- Primary loop
- while true do
- queryReactor()
- -- Active Status
- write("Reactor Status: ", true, 3, 1)
- if isActive then
- write("ONLINE", false, 0, 0, colors.green)
- else
- write("OFFLINE", false, 0, 0, colors.red)
- end
- if isActiveCooled == false then
- -- Current Stored Energy
- write("Current Stored Energy: ", true, 4, 1)
- write(energyStored.." RF", false, 0,0, colors.orange)
- -- Percentage full
- write("Energy Buffer Percentage: ", true, 5, 1)
- write(roundTwo(percentFull).."%", false, 0,0, colors.orange)
- else
- -- Current Stored Coolant
- write("Current Stored Coolant: ", true, 4, 1)
- write(coolantStored.." mB", false, 0,0, colors.orange)
- -- Current Stored Hot Fluid
- write("Current Stored Hot Fluid: ", true, 5, 1)
- write(hotFluidStored.." mB", false, 0,0, colors.orange)
- end
- -- Fuel Temp
- write("Fuel Temperature: ", true, 6, 1)
- write(roundOne(fuelTemp).." C", false, 0,0, colors.purple)
- -- Case Temp
- write("Case Temperature: ", true, 7, 1)
- write(roundOne(caseTemp).. " C", false, 0,0, colors.purple)
- -- Fuel Remaining
- write("Fuel Amount: ", true, 8, 1)
- write(math.floor(fuelAmount).." mB", false, 0,0, colors.yellow)
- -- Fuel Percentage
- write("Percentage Remaining: ", true, 9, 1)
- write(roundTwo(fuelPercent).."%", false, 0,0, colors.yellow)
- -- Waste Amount
- write("Waste Amount: ", true, 10, 1)
- write(wasteAmount.." mB", false, 0,0, colors.cyan)
- if isActiveCooled then
- -- Steam Produced
- write("Steam Produced: ", true, 11, 1)
- write(hotFluidProduced.." mB/t", false, 0,0, colors.orange)
- else
- -- Energy Produced
- write("Energy Produced: ", true, 11, 1)
- write(roundTwo(energyProduced).." RF/t", false, 0,0, colors.orange)
- end
- sleep(1)
- end
- end
- function menuLoop()
- print("Terminal Output")
- event, key = os.pullEvent("key")
- return;
- end
- --parallel.waitForAll(menuLoop(), statusLoop())
- statusLoop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement