Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Get args
- local maxRFCapacity = ...
- local periList = peripheral.getNames()
- local w, h = term.getSize()
- -- Vars
- emptyflag = 0
- offlineflag = 0
- flashflag = 0
- function MakeFuelInfo ()
- fuelMax = reactor.getFuelAmountMax()
- fuelAmount = reactor.getFuelAmount()
- fuelAmountText = math.floor(((reactor.getFuelAmount()/reactor.getFuelAmountMax())*100)+0.5)
- ProgressBar.SetTable("Fuel", fuelMax, fuelAmount, 7, w - 7,2)
- monitor.setCursorPos(w - 5, 2)
- monitor.setTextColor(colors.yellow)
- monitor.write(fuelAmountText..'%')
- end
- function MakeWasteInfo()
- wasteMax = reactor.getFuelAmountMax()
- wasteAmount = reactor.getWasteAmount()
- wasteAmountText = math.floor(((reactor.getWasteAmount()/reactor.getFuelAmountMax())*100)+0.5)
- ProgressBar.SetTable("Waste", wasteMax, wasteAmount, 7, w - 7, 3)
- monitor.setCursorPos(w - 5, 3)
- monitor.setTextColor(colors.cyan)
- monitor.write(wasteAmountText..'%')
- end
- function ControlRods(numberOfRods)
- local cursorPos = 6
- local rodLevelAvg = 0
- --Run for each rod
- for i=1, numberOfRods do
- rodLevelAvg = rodLevelAvg + (reactor.getControlRodLevel(0))
- end
- rodLevelAvg = rodLevelAvg / numberOfRods
- monitor.setTextColor(colors.green)
- monitor.setCursorPos(1,cursorPos)
- monitor.write('Rod Depths: ')
- ProgressBar.SetTable("RODS", 100, rodLevelAvg, 12, w - 7, 6)
- monitor.setCursorPos(w - 5,6)
- monitor.write(reactor.getControlRodLevel(0)..'%')
- end
- function GetCasingHeatinfo()
- if reactor.getCasingTemperature()>=650 then
- monitor.setTextColor(colors.purple)
- else if reactor.getCasingTemperature()>=950 then
- monitor.setTextColor(colors.red)
- else
- monitor.setTextColor(colors.green)
- end
- end
- casingTemp = math.floor((reactor.getCasingTemperature())+0.5)
- ProgressBar.SetTable("CasingTemp", 10000, casingTemp, 9, w - 7, 9)
- monitor.setCursorPos(w - 5, 9)
- monitor.setTextColor(colors.purple)
- monitor.write(casingTemp..' C')
- end
- function GetFuelHeatInfo()
- if reactor.getFuelTemperature()>=650 then
- monitor.setTextColor(colors.purple)
- else if reactor.getFuelTemperature()>=950 then
- monitor.setTextColor(colors.red)
- else
- monitor.setTextColor(colors.green)
- end
- end
- fuelTemp = math.floor((reactor.getFuelTemperature())+0.5)
- ProgressBar.SetTable("FuelTemp", 10000, fuelTemp, 9, w - 7, 10)
- monitor.setCursorPos(w - 5,10)
- monitor.write(fuelTemp..' C')
- end
- function GetFluxInfo()
- -- RF Stored
- rfStored = reactor.getEnergyStored()
- rfStoredFormat = rfStored / 1000000
- ProgressBar.SetTable("RFStored", 8000000, rfStored, 8, w-10,13)
- monitor.setCursorPos(w-7,13)
- monitor.setTextColor(colors.orange)
- monitor.write((math.floor(rfStoredFormat+0.5)..'Mil'))
- --------------------------------------------------
- -- RF Per Tick
- monitor.setCursorPos(1,14)
- monitor.setTextColor(colors.orange)
- rfPerTick = reactor.getEnergyProducedLastTick()
- --ProgressBar.SetTable("RFPerTick", 10000000, rfPerTick, 2,w-11,15)
- monitor.setCursorPos(1,14)
- monitor.write('RF/t: '..(math.floor(reactor.getEnergyProducedLastTick()+0.5)))
- --------------------------------------------------
- end
- -- Main Function
- function main()
- while true do
- -- Initial Setup
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.setTextColor(colors.white)
- -----------------------------------------------
- -- Make Fuel info
- --Set POS, Color, Title
- monitor.setCursorPos(1,2)
- monitor.setTextColor(colors.yellow)
- monitor.write('Fuel ')
- MakeFuelInfo()
- -----------------------------------------------
- -- Waste Bar
- --Set POS, Color, Title
- monitor.setCursorPos(1,3)
- monitor.setTextColor(colors.lightBlue)
- monitor.write('Waste ')
- MakeWasteInfo()
- -----------------------------------------------
- -- Control Rod
- --Set POS, Color, Title
- monitor.setCursorPos(1,5)
- monitor.setTextColor(colors.white)
- monitor.write('Control Rod Levels:')
- ControlRods(controlRodNumber)
- -----------------------------------------------
- -- Temps and Heat
- monitor.setCursorPos(1,8)
- monitor.setTextColor(colors.white)
- monitor.write('Temperature:')
- monitor.setCursorPos(1,9)
- monitor.setTextColor(colors.lightGray)
- monitor.write('Casing: ')
- GetCasingHeatinfo()
- --------------------------------------------------
- monitor.setCursorPos(1,10)
- monitor.setTextColor(colors.yellow)
- monitor.write('Fuel: ')
- GetFuelHeatInfo()
- --------------------------------------------------
- -- Flux Information
- monitor.setCursorPos(1,12)
- monitor.setTextColor(colors.white)
- monitor.write('Fe/Rf:')
- monitor.setCursorPos(1,13)
- monitor.setTextColor(colors.yellow)
- monitor.write('Stored: ')
- monitor.setCursorPos(1,13)
- monitor.setTextColor(colors.green)
- GetFluxInfo()
- --------------------------------------------------
- ProgressBar.DrawToPeripheral()
- monitor.setCursorPos(1,18)
- if flashflag==0 then
- flashflag=1
- if offlineflag==1 then
- monitor.setCursorPos(1,17)
- monitor.setTextColor(colors.lightGray)
- monitor.write('OFFLINE - Manual Override')
- end
- if emptyflag==1 then
- monitor.setCursorPos(1,17)
- monitor.setTextColor(colors.pink)
- monitor.write('OFFLINE - Fuel Exhausted')
- end
- if emptyflag==0 and offlineflag==0 and reactor.getControlRodLevel(0)>75 then
- monitor.setCursorPos(1,17)
- monitor.setTextColor(colors.yellow)
- monitor.write('ONLINE - Low Power Mode')
- end
- if emptyflag==0 and offlineflag==0 and reactor.getControlRodLevel(0)<=75 then
- monitor.setCursorPos(1,17)
- monitor.setTextColor(colors.orange)
- monitor.write('ONLINE - High Power Mode')
- end
- else
- flashflag=0
- monitor.setCursorPos(1,17)
- monitor.clearLine()
- end
- if reactor.getEnergyStored()< maxRFCapacity then
- reactor.setAllControlRodLevels(0+(math.floor(reactor.getEnergyStored()/80000)))
- reactor.setActive(true)
- offlineflag=0
- else
- reactor.setAllControlRodLevels(0)
- reactor.setActive(false)
- offlineflag=1
- end
- if reactor.getFuelAmount()<=100 and offlineflag==0 then
- reactor.setAllControlRodLevels(100)
- reactor.setActive(false)
- emptyflag=1
- else
- emptyflag=0
- end
- sleep(1)
- end
- end
- function dump(o)
- if type(o) == 'table' then
- local s = '{ '
- for k,v in pairs(o) do
- if type(k) ~= 'number' then k = '"'..k..'"' end
- s = s .. '['..k..'] = ' .. dump(v) .. ','
- end
- return s .. '} '
- else
- return tostring(o)
- end
- end
- function tablelength(T)
- local count = 0
- for _ in pairs(T) do count = count + 1 end
- return count
- end
- function restart()
- main()
- end
- -- Startup
- print('ReactorControl Engaged. Incoming parameters...')
- for i = 1, #periList do
- --print("I have a "..peripheral.getType(periList[i]).." attached as \""..periList[i].."\".")
- if peripheral.getType(periList[i]) == "BigReactors-Reactor" then
- reactor = peripheral.wrap(periList[i])
- maxRFCapacity = reactor.getEnergyCapacity()
- controlRodNumber = tablelength(reactor.getControlRodsLevels())
- print("Wrapped Reactor: "..periList[i])
- print("Max RF: "..maxRFCapacity)
- print("NumOfRods: "..controlRodNumber)
- end
- if peripheral.getType(periList[i]) == "monitor" then
- monitor = peripheral.wrap(periList[i])
- print("Wrapped Monitor: "..periList[i])
- --Load ProgressBar API
- if fs.exists("ProgressBar") then
- os.loadAPI('ProgressBar')
- ProgressBar.SetPeripheral(periList[i])
- print("Wrapped ProgressBar: "..periList[i])
- else
- print("Downloading API")
- shell.run("pastebin get Rzxj0KKM ProgressBar")
- print("Restarting Program")
- restart()
- end
- -- Monitor Settings
- monitor.setTextScale(1)
- monitor.setBackgroundColor(colors.black)
- end
- end
- -- Reactor Connection Checl
- if reactor then
- main()
- else
- print("reactor not connected")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement