Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Monitor Program for Big Reactors
- -- Author: FailedFace
- os.loadAPI("ReactorsAPI") -- API required for program to work
- -- NOTE: Text Colors only work on Advanced(gold) monitors
- -- Variables to Change --
- lowPower = 1000000 -- When internal buffer goes below this point the Reactor Turns on and text color is "lowPowColor".
- lowMidPower = 4000000 -- When reactor buffer is above this point the text color is changed to "midPowColor".
- highMidPower = 7000000 -- When reactor buffer is above this point the text color is changed to "highPowColor".
- highPower = 9000000 -- When internal buffer goes above this point the Reactor turns off.
- --[[ POWER LEVELS
- During the above changes the reactors scales
- with the power draw by cointrolling the rods,
- this can be seen in the "ReactorsAPI" file.
- --]]
- lowPowColor = colors.red -- See "lowPower" var note
- midPowColor = colors.yellow -- See "midPower" var note
- highPowColor = colors.green -- See "highPower" var note
- monScale = 1.5 -- Text scale for monitor, see below note.
- --[[ TEXT SCALE
- Change for monitors that are not 3Wx2H,
- This will be auto adjusted when I write the
- module and only be used as a manual override.
- --]]
- function writeToMonitor(reactor,monitor)
- monitor.clear()
- monitor.setCursorPos(1,1)
- local rawFuel = reactor.getFuelAmount()
- local currentFuel = rawFuel/1000
- local rawFuelMax = reactor.getFuelAmountMax()
- local fuelRatio = rawFuel/rawFuelMax
- monitor.setTextColor(colors.lightGray)
- monitor.write("Fuel ")
- if fuelRatio < 0.30 then
- monitor.setTextColor(lowPowColor)
- elseif fuelRatio >= 0.30 and fuelRatio < 0.75 then
- monitor.setTextColor(midPowColor)
- else
- monitor.setTextColor(highPowColor)
- end
- monitor.write(string.format("%d",currentFuel).." B")
- monitor.setCursorPos(1,2)
- monitor.setTextColor(colors.lightGray)
- monitor.write("Buffer ")
- local rawBuffer = reactor.getEnergyStored()
- local currentBuffer = rawBuffer/1000
- if rawBuffer < lowMidPower then
- monitor.setTextColor(lowPowColor)
- elseif rawBuffer >= lowMidPower and rawBuffer < highMidPower then
- monitor.setTextColor(midPowColor)
- else
- monitor.setTextColor(highPowColor)
- end
- monitor.write(string.format("%d",currentBuffer).." kRF")
- monitor.setCursorPos(1,3)
- monitor.setTextColor(colors.lightGray)
- monitor.write("Yield ")
- monitor.setTextColor(colors.white)
- monitor.write(string.format("%d",reactor.getEnergyProducedLastTick()).." RF/t")
- monitor.setCursorPos(1,4)
- monitor.setTextColor(colors.lightGray)
- monitor.write("Rods ")
- monitor.setTextColor(colors.white)
- monitor.write(reactor.getControlRodLevel(0).."%")
- monitor.setCursorPos(1,5)
- monitor.setTextColor(colors.lightGray)
- monitor.write("React ")
- monitor.setTextColor(colors.white)
- monitor.write(string.format("%d",reactor.getFuelReactivity()).."%")
- monitor.setCursorPos(1,6)
- monitor.setTextColor(colors.lightGray)
- monitor.write("Active ")
- local activity = reactor.getActive()
- if activity then
- monitor.setTextColor(highPowColor)
- else
- monitor.setTextColor(lowPowColor)
- end
- monitor.write(tostring(activity))
- monitor.setCursorPos(1,8)
- monitor.setTextColor(colors.white)
- monitor.write("CTRL+T To Terminate")
- end
- function setupMonitor(monitor) -- Not being used currently, supposed to auto adjust textscale when built
- local width, height = monitor.getSize()
- print(width)
- print(height)
- if width < 18 or height < 12 then
- print ("Monitor too small. Please use a minimum of 2x2")
- else
- ratio = math.sqrt(width*width + height*height)
- value = math.floor(ratio)
- -- monitor.setTextScale(value)
- end
- end
- reactor = peripheral.wrap(ReactorsAPI.getReactor())
- monitor = peripheral.wrap(ReactorsAPI.getMonitor())
- monitor.setTextScale(monScale)
- while true do
- sleep(1)
- ReactorsAPI.controlReactor(reactor,lowPower,highPower)
- writeToMonitor(reactor,monitor)
- end
Advertisement
Add Comment
Please, Sign In to add comment