Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Sly's reactor--
- --peripherals
- local m = {44,42,43}
- local monitors = {}
- for i=1,3 do
- monitors[i] = peripheral.wrap("monitor_"..m[i])
- end
- local rMon = monitors[2]
- local bMon = monitors[3]
- local t = {11,10}
- local turbines = {}
- for i=1,2 do
- turbines[i] = peripheral.wrap("BigReactors-Turbine_"..t[i])
- end
- local r = peripheral.wrap("BigReactors-Reactor_4")
- local core = peripheral.wrap("draconic_rf_storage_2")
- local prevT = core.getEnergyStored()
- local prev = {prevT,prevT,prevT,prevT,prevT}
- --variables
- local cols = {colors.blue,colors.lightBlue,colors.green,colors.orange,colors.red}
- local c = {1,1,1,1,1,1,1,2,2,2,3,3,3,3,3,2,2,2,2,2,2,2,2,2,3,3,3,4,4,5}
- local dir = {"Upper","Lower"}
- local cmode = {colors.green,colors.red}
- local rActive = false
- local startupState = 0
- local Lclock = 0
- local sInfo = {"Basic Mainframe: ","Reactor Interface: ","Turbine Interfaces: ","Global Reactor Control: ","Safety Systems: ","Attempting to link computer"}
- local bInfo = {}
- for i=1,5 do bInfo[i] = true end
- bInfo[1] = false
- function drawButton(id,txt,pos)
- bMon.setBackgroundColor(colors.black)
- bMon.setCursorPos(pos[1],pos[2])
- bMon.write(txt)
- if bInfo[id] then
- colsT = {colors.green,colors.gray}
- else
- colsT = {colors.gray,colors.red}
- end
- bMon.setCursorPos(pos[1]+10,pos[2])
- bMon.setBackgroundColor(colsT[1])
- bMon.write(" ")
- bMon.setCursorPos(pos[1]+11,pos[2])
- bMon.write(" ON ")
- bMon.setCursorPos(pos[1]+16,pos[2])
- bMon.setBackgroundColor(colsT[2])
- bMon.write(" ")
- bMon.setCursorPos(pos[1]+17,pos[2])
- bMon.write(" OFF ")
- bMon.setBackgroundColor(colors.black)
- end
- function toRead(l)
- local pow = math.floor(math.log(l)/math.log(1000))
- local temp = {"","K","M","B","T"}
- return (math.ceil( ( ( l/ (1000^pow) )*100 )-0.5)/100)..temp[pow+1]
- end
- function drawGauge(i,n,pos)
- local tur = turbines[i]
- --local mon = monitors[m]
- --mon.setTextScale(0.5)
- if tur.getActive() then
- act = 1
- else
- act = 2
- end
- local RPM = tur.getRotorSpeed()
- local energyLastTick = tur.getEnergyProducedLastTick()
- local enT = ""
- if energyLastTick<1000 then
- enT = math.ceil(energyLastTick-0.5).."RF/t"
- else
- enT = (math.ceil((energyLastTick/10)-0.5)/100).."kRF/t"
- end
- local flowRate = tur.getFluidFlowRate()
- if tur.getInductorEngaged() then
- coils = "Engaged"
- else
- coils = "Disengaged"
- end
- --[[local RPMp = math.ceil(((RPM/2000) * 30) - 0.5)
- mon.setTextColor(colors.black)
- for y = 0,31 do
- if y/3 == math.ceil(y/3) then
- txt = math.ceil((y/30)*2000).." "
- posx = pos[1] - (#txt-1)
- else
- posx = pos[1]
- txt = " "
- end
- mon.setCursorPos(posx,pos[2]+(32-y))
- mon.setBackgroundColor(colors.white)
- mon.setTextColor(colors.black)
- mon.write(txt)
- if y==0 or y == 31 then
- mon.setBackgroundColor(colors.white)
- elseif y<=RPMp then
- mon.setBackgroundColor(cols[c[y] ])
- else
- mon.setBackgroundColor(colors.black)
- end
- mon.setTextColor(colors.white)
- mon.write(string.rep(" ",8))
- mon.setBackgroundColor(colors.white)
- mon.write(" ")
- mon.setBackgroundColor(colors.black)
- end ]]--
- local m3 = monitors[n]
- info = {dir[i],math.ceil(RPM-0.5).."RPM",enT,flowRate.."Mb/t",coils}
- for l = 1,#info do
- m3.setBackgroundColor(cmode[act])
- m3.setCursorPos(-9+(i*12),l+2)
- m3.write(string.rep(" ",10))
- m3.setCursorPos(-9+(i*12),l+2)
- m3.write(info[l])
- m3.setBackgroundColor(colors.black)
- end
- end
- while true do
- Lclock = Lclock + 1
- if Lclock >= 8 then Lclock = 0 end
- --Turbines
- --monitors[1].setBackgroundColor(colors.black)
- --monitors[1].clear()
- local m2 = monitors[1]
- m2.clear()
- m2.setCursorPos(4,1)
- m2.write("Turbine Information")
- m2.setTextScale(1.5)
- for i=1,2 do
- drawGauge(i,1,{-13+(i*32),3})
- end
- --Reactor
- local Active = r.getActive()
- rMon.setTextColor(colors.white)
- if Active and not rActive then
- if startupState == 0 then
- rMon.clear()
- end
- startupState = startupState + 1
- if startupState <12 then
- if startupState/2 ~= math.ceil(startupState/2) then
- local line = (startupState+1 )/ 2
- rMon.setTextColor(colors.white)
- rMon.setCursorPos(1,line)
- rMon.write(sInfo[line])
- else
- rMon.setTextColor(colors.green)
- rMon.write("Active")
- end
- elseif startupState<15 then
- rMon.write(".")
- elseif startupState == 16 then
- rMon.setCursorPos(1,8)
- rMon.write("Successful!")
- end
- if startupState == 18 then
- startupState = 0
- rActive = true
- for i=1,2 do bInfo[i+1] = true end
- end
- else
- rMon.clear()
- end
- if rActive and not Active then
- rActive = false
- for i=1,2 do bInfo[i+1] = false end
- end
- if rActive then
- rMon.clear()
- rMon.setTextScale(1)
- rMon.setTextColor(colors.white)
- rMon.setCursorPos(15,1)
- rMon.write("Reactor Information")
- rMon.setCursorPos(6,3)
- rMon.write("Reactor Status: ")
- rMon.setTextColor(colors.green)
- rMon.setCursorPos(32,3)
- rMon.write("ONLINE")
- local En = 0
- local enD = ""
- for i=1,2 do En = En+turbines[i].getEnergyProducedLastTick() end
- enD = toRead(En).."rf/t"
- local rInfo = {
- "Fuel Amount: ",r.getFuelAmount().."mB ("..(math.ceil((r.getFuelAmount()/r.getFuelAmountMax()*100)-0.5)).."%)",
- "Waste Amount: ",r.getWasteAmount().."mB ("..(math.ceil((r.getWasteAmount()/10)-0.5)).."%)",
- "Water Amount: ",r.getCoolantAmount().."mB ("..(math.ceil((r.getCoolantAmount()/r.getCoolantAmountMax()*100)-0.5)).."%)",
- "Steam Amount: ",r.getHotFluidAmount().."mB ("..(math.ceil((r.getHotFluidAmount()/r.getHotFluidAmountMax()*100)-0.5)).."%)",
- "Core/Casing Temper: ",math.ceil(r.getCasingTemperature()-0.5).." / "..math.ceil(r.getFuelTemperature()-0.5),
- "Fuel Used/tick: ",math.ceil(r.getFuelConsumedLastTick()-0.5).."mB/t",
- "Steam Produced/tick: ",math.ceil(r.getHotFluidProducedLastTick()-0.5).."mB/t",
- "Fuel Reactivity: ",math.ceil(r.getFuelReactivity()-0.5).."%",
- "Total Energy/tick: ",enD
- }
- for i=1,#rInfo do
- if i/2 ~= math.ceil(i/2) then
- line = (i+1)/2
- rMon.setCursorPos(6,line+3)
- rMon.setTextColor(colors.white)
- else
- line = (i)/2
- rMon.setCursorPos(32,line+3)
- rMon.setTextColor(colors.green)
- end
- rMon.write(rInfo[i])
- end
- st = core.getEnergyStored()
- ma = core.getMaxEnergyStored()
- stored = toRead(st)
- max = toRead(ma)
- rMon.setBackgroundColor(colors.black)
- rMon.setCursorPos(4,15)
- rMon.write(stored.."rf / "..max.."rf ("..math.ceil(((st/ma)*100)-0.5).."%)")
- pStored = math.ceil(((st/ma)*30)-0.5)
- for i=1,3 do
- rMon.setCursorPos(3,15+i)
- if i==2 then
- rMon.write(" ")
- rMon.setBackgroundColor(colors.blue)
- rMon.write(string.rep(" ",pStored))
- rMon.setBackgroundColor(colors.black)
- rMon.write(string.rep(" ",30-pStored))
- rMon.setBackgroundColor(colors.gray)
- rMon.write(" ")
- else
- rMon.setBackgroundColor(colors.gray)
- rMon.write(string.rep(" ",32))
- end
- end
- rMon.setBackgroundColor(colors.black)
- enLastTick = (st - prev[1])
- for i=1,#prev-1 do
- enLastTick = enLastTick + (prev[i]-prev[i+1])
- end
- enLastTick = enLastTick / #prev
- if enLastTick>0 then
- enToFill = ma-st
- ticksToFill = enToFill/enLastTick
- minsToFill = "ETA to fill: "..math.ceil((ticksToFill/(20*60))-0.5).." minutes"
- else
- minsToFill = "ETA to fill: Infinity"
- end
- rMon.setCursorPos(4,19)
- rMon.write(minsToFill)
- table.insert(prev, 1, core.getEnergyStored())
- table.remove(prev, 6)
- else
- if not Active then
- if Lclock < 4 then
- rMon.setTextColor(colors.red)
- rMon.setTextScale(4)
- rMon.setCursorPos(4,2)
- rMon.write("REACTOR")
- rMon.setCursorPos(4,3)
- rMon.write("OFFLINE")
- end
- end
- end
- bMon.clear()
- bMon.setCursorPos(18,1)
- bMon.write("Controls")
- drawButton(1,"Reactor:",{10,2})
- bMon.setCursorPos(15,4)
- bMon.write("Upper Turbine")
- drawButton(2,"Active:",{10,5})
- drawButton(4,"Coils:",{10,6})
- bMon.setCursorPos(15,8)
- bMon.write("Lower Turbine")
- drawButton(3,"Active:",{10,9})
- drawButton(5,"Coils:",{10,10})
- r.setActive(bInfo[1])
- for i=1,2 do turbines[i].setActive(bInfo[i+1]) end
- for i=1,2 do turbines[i].setInductorEngaged(bInfo[i+3]) end
- os.startTimer(0.35)
- while true do
- local evt = {os.pullEvent()}
- if evt[1] == "timer" then
- break
- elseif evt[1] == "monitor_touch" then
- if evt[2] == "monitor_43" and redstone.getInput("right") == true then
- local x = evt[3]
- local y = evt[4]
- if y==2 then
- if x>=23 and x<=26 then
- bInfo[1] = true
- elseif x>=29 and x<=33 then
- bInfo[1] = false
- end
- elseif y==5 then
- if x>=13 and x<=16 then
- bInfo[2] = true
- elseif x>=19 and x<=23 then
- bInfo[2] = false
- elseif x>=38 and x<=41 then
- bInfo[3] = true
- elseif x>=44 and x<=48 then
- bInfo[3] = false
- end
- elseif y==6 then
- if x>=13 and x<=16 then
- bInfo[4] = true
- elseif x>=19 and x<=23 then
- bInfo[4] = false
- elseif x>=38 and x<=41 then
- bInfo[5] = true
- elseif x>=44 and x<=48 then
- bInfo[5] = false
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement