Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------------------------------------------------
- ---------------------------------------------------------------
- -- VARIABLES
- -- setup
- numCaps = 8
- enablePerc = 50
- disablePerc = 90
- -- globals (don't change)
- numReacs = 0
- curEn = 0
- maxEn = 0
- percEn = 0
- usedEn = 0
- rfGen = 0
- reacsOnline = 0
- fuelUse = {}
- coreTemp = {}
- rfGens = {}
- ---------------------------------------------------------------
- ---------------------------------------------------------------
- -- FIND PERIPHERALS
- cap = peripheral.find("tile_blockcapacitorbank_name")
- mon = peripheral.find("monitor")
- mon.setTextScale(1)
- local names = {}
- local function filter(name)
- table.insert(names,name)
- return true
- end
- peripheral.find("BigReactors-Reactor",filter)
- numReacs = table.getn(names)
- local reacs = {}
- for i=1,numReacs,1 do
- reacs[i] = peripheral.wrap(names[i])
- end
- ---------------------------------------------------------------
- ---------------------------------------------------------------
- -- FUNCTIONS
- maxEn = cap.getMaxEnergyStored()
- function process()
- -- Energy (Capacitors)
- curEn = cap.getEnergyStored()
- percEn = math.floor((curEn/maxEn)*100)
- sleep(0.1)
- usedEn = (cap.getEnergyStored()-curEn)/2
- usedEn = usedEn*numCaps
- -- Reactors
- if percEn < enablePerc then
- enableReactor = true
- disableReactor = false
- elseif percEn > disablePerc then
- disableReactor = true
- enableReactor = false
- else
- enableReactor = false
- disableReactor = false
- end
- rfGen = 0
- reacsOnline = 0
- for i=1,numReacs,1 do
- -- rf gen
- rfGen = rfGen+reacs[i].getEnergyProducedLastTick()
- rfGens[i]=reacs[i].getEnergyProducedLastTick()
- -- auto enable-disable
- if enableReactor then
- reacs[i].setActive(enableReactor)
- end
- if disableReactor then
- reacs[i].setActive(false)
- end
- -- currently online
- if reacs[i].getActive() then
- reacsOnline = reacsOnline + 1
- end
- -- fuel use
- fuelUse[i] = reacs[i].getFuelConsumedLastTick()
- fuelUse[i] = math.floor(fuelUse[i]*100)
- fuelUse[i] = fuelUse[i]/100
- -- core temps
- coreTemp[i] = reacs[i].getFuelTemperature()
- end
- end
- function display()
- -- clear
- mon.clear()
- mon.setTextColor(colors.white)
- -- general display
- mon.setCursorPos(1,1)
- mon.write("RF Total: "..math.floor((percEn*maxEn*numCaps)/1e8).."M/"..math.floor(maxEn/1e6)*numCaps.."M")
- --mon.write("RF Stored: "..percEn.."%")
- sleep(0.1)
- mon.setCursorPos(21,1)
- mon.write("RF Used: ")
- if usedEn < 0 then
- mon.setTextColor(colors.red)
- else
- mon.setTextColor(colors.green)
- end
- mon.write(usedEn.." RF/t")
- mon.setTextColor(colors.white)
- mon.setCursorPos(21,2)
- mon.write("RF Gen: ")
- mon.setTextColor(colors.green)
- mon.write(math.floor(rfGen).." RF/t")
- mon.setTextColor(colors.white)
- mon.setCursorPos(1,2)
- mon.write("Online: "..reacsOnline.." / "..numReacs)
- local m = 38
- local max = math.floor(m*(percEn/100))
- mon.setCursorPos(1,3)
- mon.setBackgroundColor(colors.red)
- mon.write(" ")
- mon.setCursorPos(m+1,3)
- mon.write(" ")
- mon.setCursorPos(2,3)
- mon.setTextColor(colors.white)
- local text = ""..math.floor((percEn*maxEn*numCaps)/1e8).."M/"..math.floor(maxEn/1e6)*numCaps.."M".." ("..percEn.."%)"
- local offset = math.floor(m/2 - string.len(text)/2)
- for i=1,m,1 do
- if i < max then
- mon.setBackgroundColor(colors.green)
- else
- mon.setBackgroundColor(colors.black)
- end
- local k = i-offset
- if i >= offset and k <= string.len(text) then
- mon.write(string.sub(text,k,k))
- else
- mon.write(" ")
- end
- end
- mon.setBackgroundColor(colors.black)
- -- individual display
- local div = math.ceil(numReacs/2)
- local x = 0
- local y = 4
- local numStats = 5
- for i=1,numReacs,1 do
- if i <= div then
- x = 1
- y = 5 + (i-1)*numStats
- else
- x = 21
- y = 5 + (i - div - 1)*numStats
- end
- mon.setCursorPos(x,y)
- mon.setTextColor(colors.blue)
- mon.write("Reactor "..i..": ")
- mon.setCursorPos(x+2,y+1)
- mon.setTextColor(colors.yellow)
- mon.write("Fuel - "..fuelUse[i].." MB/t")
- mon.setCursorPos(x+2,y+2)
- mon.setTextColor(colors.orange)
- mon.write("Temp - "..math.floor(coreTemp[i]).."c")
- mon.setCursorPos(x+2,y+3)
- mon.setTextColor(colors.green)
- mon.write("RF Gen - "..math.floor(rfGens[i]).." RF/t")
- end
- end
- ---------------------------------------------------------------
- ---------------------------------------------------------------
- -- MAIN LOOP
- while true do
- process()
- display()
- sleep(1)
- end
- ---------------------------------------------------------------
- ---------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement