Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- reactorA = peripheral.wrap("BigReactors-Reactor_17")
- reactorB = peripheral.wrap("BigReactors-Reactor_16")
- reactorC = peripheral.wrap("BigReactors-Reactor_18")
- reactorD = peripheral.wrap("BigReactors-Reactor_19")
- reactorE = peripheral.wrap("BigReactors-Reactor_20")
- reactorF = peripheral.wrap("BigReactors-Reactor_21")
- turbineA = peripheral.wrap("BigReactors-Turbine_8")
- turbineB = peripheral.wrap("BigReactors-Turbine_7")
- turbineC = peripheral.wrap("BigReactors-Turbine_9")
- turbineD = peripheral.wrap("BigReactors-Turbine_10")
- turbineE = peripheral.wrap("BigReactors-Turbine_11")
- turbineF = peripheral.wrap("BigReactors-Turbine_12")
- monitor = peripheral.wrap("monitor_26")
- monitorB = peripheral.wrap("back")
- monitor.setBackgroundColor(colors.white)
- monitorB.setBackgroundColor(colors.white)
- monitor.clear()
- monitorB.clear()
- function topbar()
- monitor.setCursorPos(1,1)
- monitorB.setCursorPos(1,1)
- monitor.setBackgroundColor(colors.black)
- monitorB.setBackgroundColor(colors.black)
- monitor.setTextColor(colors.white)
- monitorB.setTextColor(colors.white)
- monitor.write("Turbine-Reactor Control Interface ")
- monitorB.write("Turbine-Reactor Status Interface ")
- end
- function valint(x,y,name,val,valN,length,device)
- val = math.floor(val*100)/100
- device.setCursorPos(x,y)
- device.setBackgroundColor(colors.lightGray)
- for i = 0,length do
- device.setCursorPos(x+i,y)
- device.write(" ")
- end
- device.setCursorPos(x,y)
- device.write(name..": ")
- device.setCursorPos(x+(length/2),y)
- device.write(val.." "..valN)
- end
- function background(device)
- x,y = device.getSize()
- --print(x)
- device.setTextColor(colors.black)
- device.setBackgroundColor(colors.white)
- for iy = 1,y do
- for ix = 1,x do
- device.setCursorPos(ix,iy)
- device.write(".")
- end
- end
- end
- function loadMenu()
- monitor.setBackgroundColor(colors.black)
- xm,ym = monitor.getSize()
- for iy=0,ym do
- for ix=0,10 do
- monitor.setCursorPos((xm-10)+ix,iy)
- monitor.write(" ")
- end
- end
- monitor.setTextColor(colors.lightGray)
- monitor.setCursorPos(xm-8,3)
- monitor.write(" Blank >")
- monitor.setCursorPos(xm-8,10)
- monitor.write(" Blank >")
- monitor.setCursorPos(xm-8,17)
- monitor.write(" Blank >")
- monitor.setCursorPos(xm-8,24)
- monitor.write(" Blank >")
- end
- function getValues(reactor,turbine,num)
- data = {
- tempC = reactor.getFuelTemperature(),
- tempM = 2000,
- fuelC = reactor.getFuelAmount(),
- fuelM = 20000,
- enerC = turbine.getEnergyStored(),
- enerM = 1000000,
- fuelU = reactor.getFuelConsumedLastTick(),
- fuelR = reactor.getFuelReactivity(),
- enerP = turbine.getEnergyProducedLastTick(),
- fuelW = reactor.getWasteAmount(),
- rodsP = reactor.getControlRodLevel(0),
- rodsM = 100,
- hotfP = reactor.getHotFluidProducedLastTick(),
- hotfC = reactor.getHotFluidAmount(),
- hotfM = reactor.getHotFluidAmountMax(),
- coolC = reactor.getCoolantAmount(),
- coolM = reactor.getCoolantAmountMax(),
- rotoS = turbine.getRotorSpeed()
- }
- end
- function indic(x,y,name,val,length,device)
- device.setBackgroundColor(colors.lightGray)
- device.setTextColor(colors.black)
- for i=0,length do
- device.setCursorPos(x+i,y)
- device.write(" ")
- end
- device.setCursorPos(x+2,y)
- device.write(name)
- device.setCursorPos(x,y)
- if val == true then
- status = colors.green
- elseif val == false then
- status = colors.red
- else
- status = colors.orange
- end
- device.setBackgroundColor(status)
- device.write(" ")
- end
- function inp()
- input = rs.getBundledInput("left")
- --print(input)
- if input >= 8 then
- d = true
- input = input - 8
- else
- d = false
- end
- if input >= 4 then
- c = true
- input = input - 4
- else
- c = false
- end
- if input >= 2 then
- b = true
- input = input - 2
- else
- b = false
- end
- if input >= 1 then
- a = true
- else
- a = false
- end
- --print(a)
- --print(b)
- --print(c)
- end
- function bar(x,y,name,valA,valB,length,disp,mult,col,device)
- if disp == true or disp == "bvottom" then
- if disp ~= true then
- a = 2
- else
- a = 0
- end
- perc = math.floor((valA/valB)*100*100)/100
- device.setCursorPos(x,y+a)
- device.setBackgroundColor(colors.white)
- device.setTextColor(colors.black)
- for ix = 0,length-1 do
- device.setCursorPos(x+ix,y+a)
- device.write(" ")
- end
- device.setCursorPos(x,y)
- device.write(name)
- device.setCursorPos(x+length-6,y+a)
- device.write(perc)
- device.setCursorPos(x+length-1,y+a)
- device.write("%")
- if valA > valB then
- valB = valA
- end
- end
- if disp == true then
- device.setBackgroundColor(colors.gray)
- for i=0,length-1 do
- device.setCursorPos(x+i,y+1)
- device.write(" ")
- end
- end
- im = (valA / valB) * length
- device.setBackgroundColor(col)
- for i=0,im-1 do
- device.setCursorPos(x+i,y+1)
- device.write(" ")
- end
- end
- function indicate(p,y)
- if p == true then
- monitor.setBackgroundColor(colors.green)
- else
- monitor.setBackgroundColor(colors.red)
- end
- monitor.setCursorPos(41,y)
- monitor.write(" ")
- end
- function turbineLayout(reactor,turbine,x,y)
- getValues(reactor,turbine)
- bar(x,y,"Fuel Amount",data.fuelC,data.fuelM,20,true,1,colors.yellow,monitorB)
- bar(x,y+3,"Rotor Speed",data.rotoS,2000,20,true,1,colors.cyan,monitorB)
- bar(x,y+6,"Energy Buffer",data.enerC,data.enerM,20,true,1,colors.red,monitorB)
- end
- function blanky(x,y,length,height,color,device)
- device.setBackgroundColor(color)
- for iy = 0,height do
- for i = 0,length do
- device.setCursorPos(x+i,y+iy)
- device.write(" ")
- end
- end
- end
- background(monitorB)
- background(monitor)
- topbar()
- while true do
- getValues(reactorA,turbineA)
- inp()
- loadMenu()
- turbineLayout(reactorA,turbineA,4,4)
- turbineLayout(reactorB,turbineB,28,4)
- turbineLayout(reactorC,turbineC,4,14)
- turbineLayout(reactorD,turbineD,28,14)
- turbineLayout(reactorE,turbineE,4,24)
- turbineLayout(reactorF,turbineF,28,24)
- blanky(6,7,22,18,colors.gray,monitor)
- monitor.setTextColor(colors.white)
- monitor.setBackgroundColor(colors.black)
- monitor.setCursorPos(6,7)
- monitor.write(" Reactor Power Status: ")
- indic(7,9,"REACTOR A",reactorA.getActive(),20,monitor)
- indic(7,12,"REACTOR B",reactorB.getActive(),20,monitor)
- indic(7,15,"REACTOR C",reactorC.getActive(),20,monitor)
- indic(7,18,"REACTOR D",reactorD.getActive(),20,monitor)
- indic(7,21,"REACTOR E",reactorE.getActive(),20,monitor)
- indic(7,24,"REACTOR F",reactorF.getActive(),20,monitor)
- sleep(0.2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement