Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- monitors = {peripheral.find("monitor")}
- mon = monitors[1]
- monT = monitors[2]
- monR = monitors[3]
- monX, monY = mon.getSize()
- monTX, monTY = monT.getSize()
- reactors = {peripheral.find("BigReactors-Reactor")}
- if reactors == nil then
- error("Kein Reaktor gefunden!")
- end
- reactor = reactors[1]
- eReactor = reactors[2]
- if reactor.isActivelyCooled() == false then
- reactor = reactors[2]
- eReactors = reactors[1]
- end
- turbines = {peripheral.find("BigReactors-Turbine")}
- if turbines == nil then
- error("Keine Turbine gefunden!")
- end
- function clear()
- for counter = 1, #monitors do
- monitor = monitors[counter]
- monitor.setBackgroundColor(colors.black)
- monitor.clear()
- monitor.setCursorPos(1,1)
- end
- end
- function drawText(monitor,x , y, text, color_txt, color_bg)
- monitor.setBackgroundColor(color_bg)
- monitor.setTextColor(color_txt)
- monitor.setCursorPos(x,y)
- monitor.write(text)
- end
- function drawLine(monitor, x, y, length, size, color_bar)
- for yPos = y, y+size-1 do
- monitor.setBackgroundColor(color_bar)
- monitor.setCursorPos(x,yPos)
- monitor.write(string.rep(" ",length))
- end
- end
- function getRodPro()
- rodPro = 0
- for rodIndex = 0,reactor.getNumberOfControlRods()-1 do
- rodPro = rodPro + reactor.getControlRodLevel(rodIndex)
- end
- return 1-((rodPro / reactor.getNumberOfControlRods())/100.0)
- end
- function getTurbineSpeedPro(turbine)
- speed = turbine.getRotorSpeed()
- if speed > 3500 then
- speed = 3500
- end
- return speed/3500.0
- end
- function adjustReactor()
- if reactor.getCasingTemperature() > 2000 then
- reducedRod()
- end
- if reactor.getCasingTemperature() < 1000 then
- higherRod()
- end
- end
- function reducedRod()
- for rodIndex = 0, reactor.getNumberOfControlRods()-1 do
- if reactor.getControlRodLevel(rodIndex) < 100 then
- reactor.setControlRodLevel(rodIndex, reactor.getControlRodLevel(rodIndex)+10)
- break
- end
- end
- end
- function higherRod()
- for rodIndex = 0, reactor.getNumberOfControlRods()-1 do
- if reactor.getControlRodLevel(rodIndex) > 0 then
- reactor.setControlRodLevel(rodIndex, reactor.getControlRodLevel(rodIndex)-10)
- break
- end
- end
- end
- function adjustTurbine(turbine)
- rate = turbine.getFluidFlowRateMax()
- if turbine.getEnergyStored() > 900000 then
- if rate > 0 then
- rate = rate - 100
- end
- turbine.setFluidFlowRateMax(rate)
- end
- if turbine.getEnergyStored() < 400000 then
- if rate < 2000 then
- rate = rate + 100
- end
- turbine.setFluidFlowRateMax(rate)
- end
- end
- function getEnergie()
- energie = 0
- for counter = 1, #turbines do
- turbine = turbines[counter]
- energie = energie + turbine.getEnergyStored()
- end
- return energie
- end
- function manageEReactor()
- if getEnergie() == 0 then
- higherEReactor()
- else
- lowerEReactor()
- end
- end
- function higherEReactor()
- end
- while true do
- clear()
- drawText(mon,monX/2,1,"Reactor", colors.green, colors.black)
- length = monX-2
- drawLine(mon,2,2,length,2,colors.gray)
- drawLine(mon,2,2,length*getRodPro(),2,colors.green)
- adjustReactor()
- for turbineCounter = 1, #turbines do
- turbine = turbines[turbineCounter]
- startPos = (turbineCounter-1)*4
- drawText(monT, monX/2,startPos+1,"Turbine", colors.green,colors.black)
- drawLine(monT, 2,startPos+2,length,2,colors.gray)
- drawLine(monT, 2,startPos+2,length*getTurbineSpeedPro(turbine),2,colors.blue)
- adjustTurbine(turbine)
- end
- drawText(mon, monX/2, 5, "Heat", colors.orange, colors.black)
- drawLine(mon, 2, 6, length, 2, colors.gray)
- if reactor.getCasingTemperature() <= 2000 then
- drawLine(mon, 2, 6, length*(reactor.getCasingTemperature()/2000), 2, colors.orange)
- else
- drawLine(mon, 2, 6, length, 2, colors.red)
- end
- drawText(mon, monX/2,monY-3,"Energie", colors.red, colors.black)
- drawLine(mon, 2,monY-2,length,2,colors.gray)
- drawLine(mon, 2,monY-2,length*(getEnergie()/(#turbines*1000000)), 2, colors.red)
- manageEReactor()
- os.sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement