Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function clean()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1,1)
- end
- function cleanMon()
- m.setBackgroundColor(colors.black)
- m.clear()
- m.setCursorPos(1,1)
- end
- function center(text,index,y)
- if index == m then
- screen = m
- elseif index == m2 then
- screen = m2
- else
- screen = tWindow[index]
- end
- w,h = screen.getSize()
- _text = tostring(text)
- sl = string.len(_text)
- screen.setCursorPos((w/2)-(sl/2),y)
- screen.write(_text)
- end
- clean()
- peripherals = peripheral.getNames()
- t = {}
- for i=1,#peripherals do
- --print(peripherals[i])
- type = peripheral.getType(peripherals[i])
- if type == "BigReactors-Turbine" then
- table.insert(t,peripheral.wrap(peripherals[i]))
- print("adding new turbine ")
- elseif type == "BigReactors-Reactor" then
- if not r then
- r = peripheral.wrap(peripherals[i])
- print("got the reactor")
- end
- end
- end
- m = peripheral.wrap("monitor_20")
- m2 = peripheral.wrap("monitor_21")
- if not r then
- error("No Reactor Found")
- end
- if not m then
- error("No Monitor Found")
- end
- if not m2 then
- error("No Secondary Monitor Found")
- end
- cleanMon()
- --cpu = term.redirect(m)
- clean()
- -- Prepare Windows for Turbines
- -- 4 windows per line, 2 lines, 17 wide each, 20 high each
- tWindow = {}
- height = 8
- for i=1,#t do
- if i <= 4 then
- y = 4
- xsub = 0
- elseif i <= 8 then
- y = 4 + (1 + height)
- xsub = 4
- elseif i <= 12 then
- y = 4 + (1 + height) * 2
- xsub = 8
- else
- y = 4 + (1 + height) * 3
- xsub = 12
- end
- x = 1 + (17 * ((i-1) - xsub) ) + ((i-1)-xsub)
- --if i > 4 and i < 9 then
- -- x = x - i
- --end
- table.insert(tWindow,window.create(m,x,y,17,height,true))
- end
- -- Show Turbine Stats
- while true do
- center("TURBINES",m,1)
- center("--------",m,2)
- x,y= 1,4
- totalPowerGen = 0
- for i=1,#t do
- if t[i].getConnected() then
- tWindow[i].clear()
- center(i,i,1)
- if t[i].getActive() then
- tWindow[i].setBackgroundColor(colors.green)
- else
- tWindow[i].setBackgroundColor(colors.red)
- end
- center("POWER",i,2)
- tWindow[i].setBackgroundColor(colors.gray)
- center(math.floor(t[i].getEnergyStored()).. "RF",i,6)
- center(math.floor(t[i].getRotorSpeed()).." RPM",i,7)
- center(math.floor(t[i].getEnergyProducedLastTick()) .. "RF/T",i,8)
- if t[i].getInductorEngaged() then
- tWindow[i].setBackgroundColor(colors.green)
- else
- tWindow[i].setBackgroundColor(colors.red)
- end
- center("COIL ",i,4)
- tWindow[i].setBackgroundColor(colors.black)
- totalPowerGen = totalPowerGen + t[i].getEnergyProducedLastTick()
- end
- end
- -- Show Reactor Stats
- m2.clear()
- center("Reactor Info",m2,1)
- center("____________",m2,2)
- if r.getConnected() then
- if r.getActive() then
- m2.setBackgroundColor(colors.green)
- else
- m2.setBackgroundColor(colors.red)
- end
- center("POWER",m2,4)
- m2.setBackgroundColor(colors.black)
- center("Fuel Temp: " .. math.floor(r.getFuelTemperature()),m2,6)
- center("Case Temp: " .. math.floor(r.getCasingTemperature()),m2,7)
- center("Fuel Amount: ".. math.floor(r.getFuelAmount()).."/"..math.floor(r.getFuelAmountMax()),m2,8)
- center("Steam Created: " .. r.getHotFluidProducedLastTick().." mB/t",m2,9)
- center("Fuel Rate: ".. r.getFuelConsumedLastTick() .. " mB/t",m2,10)
- center("Fuel Reactivity: ".. math.floor(r.getFuelReactivity()).. "%",m2,11)
- loc = 15
- height = 10
- water = r.getCoolantAmount()
- waterMax = r.getCoolantAmountMax()
- waterBlock = waterMax/height
- numWaterBlocks = math.floor(water/waterBlock)
- steam = r.getHotFluidAmount()
- steamMax = r.getHotFluidAmountMax()
- steamBlock = steamMax/height
- numSteamBlocks = math.floor(steam/steamBlock)
- sw,sh = m2.getSize()
- m2.setBackgroundColor(colors.lightGray)
- for l=1,height do
- m2.setCursorPos(5,loc-l)
- m2.write(" ")
- m2.setCursorPos(8,loc-l)
- m2.write(" ")
- m2.setCursorPos(sw-5,loc-l)
- m2.write(" ")
- m2.setCursorPos(sw-8,loc-l)
- m2.write(" ")
- end
- m2.setCursorPos(5,loc - height - 1)
- m2.write(" ")
- m2.setCursorPos(sw-8,loc - height - 1)
- m2.write(" ")
- m2.setCursorPos(5,loc)
- m2.write(" ")
- m2.setCursorPos(sw-8,loc)
- m2.write(" ")
- m2.setBackgroundColor(colors.blue)
- for l=1,numWaterBlocks do
- m2.setCursorPos(6,loc-l)
- m2.write(" ")
- end
- m2.setBackgroundColor(colors.gray)
- for l=1,numSteamBlocks do
- m2.setCursorPos(sw-7,loc-l)
- m2.write(" ")
- end
- m2.setBackgroundColor(colors.black)
- end
- timer = os.startTimer(.5)
- while true do
- event,side,x,y = os.pullEvent()
- if event == "timer" then
- break
- elseif event == "monitor_touch" then
- -- check coords for button push
- if side == "monitor_21" then
- local w,h = screen.getSize()
- powerX = (w/2)-(5/2)
- if x >= powerX and x <= powerX + 5 and y == 4 then
- if r.getActive() then
- -- disable input of yellorium
- rs.setBundledOutput("bottom",0)
- -- disable reactor
- r.setActive(false)
- -- dump fuel
- repeat
- r.doEjectFuel()
- sleep(.5)
- until r.getFuelAmount() < 1000
- else
- -- enable input of yellorium
- rs.setBundledOutput("bottom",colors.black)
- -- enable reactor
- r.setActive(true)
- end
- end
- break
- end
- end
- end
- --os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement