Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local turbines = {peripheral.find("BigReactors-Turbine")}
- local reactor = peripheral.find("BigReactors-Reactor")
- local mon = peripheral.find("monitor")
- local cap = peripheral.find("tile_blockcapacitorbank_name")
- local capCount = 27
- local capMax = 25000000
- local turbineMax = 10000000
- function clear()
- mon.setBackgroundColor(colors.black)
- mon.clear()
- mon.setCursorPos(1,1)
- end
- function draw_line(x, y, length, color)
- mon.setBackgroundColor(color)
- mon.setCursorPos(x,y)
- mon.write(string.rep(" ", length))
- end
- function progress_bar(x, y, length, minVal, maxVal, bar_color, bg_color)
- draw_line(x, y, length, bg_color)
- local barSize = math.floor((minVal/maxVal) * length)
- draw_line(x, y, barSize, bar_color)
- end
- function draw_text(x, y, text, text_color, bg_color)
- mon.setBackgroundColor(bg_color)
- mon.setTextColor(text_color)
- mon.setCursorPos(x,y)
- mon.write(text)
- end
- while true do
- local maxEnergy = (capCount * capMax) + (turbineMax * #turbines)
- local energyStored = cap.getEnergyStored() * capCount
- local percentage = math.ceil((energyStored / maxEnergy) * 100)
- local steam = reactor.getHotFluidAmount()
- local steamMax = reactor.getHotFluidAmountMax()
- local steamPercent = math.ceil(steam / steamMax) * 100
- local controlLevel = reactor.getControlRodLevel(1)
- local reactorActive = false
- if percentage < 20 then
- if reactor.getActive == false then
- reactor.setActive(true)
- end
- for k,v in ipairs(turbines) do
- if v.getActive() == false then
- v.setActive(true)
- v.setVentOverflow()
- v.setFluidFlowRateMax(2000)
- v.setInductorEngaged(false)
- end
- end
- end
- if percentage <= 90 then
- if reactorActive == true then
- if steamPercent < 80 then
- reactor.setAllControlRodLevels(controlLevel + 5)
- end
- if steamPercent == 100 then
- reactor.setAllControlRodLevels(controlLevel -1)
- end
- for k,v in ipairs(turbines) do
- local speed = v.getRotorSpeed()
- local flowRate = v.getFluidFlowRateMax()
- if v.getInductorEngaged == false then
- if speed >= 1500 then
- v.setInductorEngaged(true)
- end
- if speed < 1800 then
- v.setFluidFlowRateMax(flowRate+1)
- end
- if speed > 1815 then
- v.setFluidFlowRate(flowRate-1)
- end
- end
- end
- end
- end
- if percentage > 90 then
- reactor.setActive(false)
- reactor.setAllControlRodLevels(100)
- for k,v in ipairs(turbines) do
- v.setActive(false)
- v.setVentOff(false)
- v.setFluidFlowRateMax(0)
- end
- end
- --render
- clear()
- draw_line(1,1,61,colors.green)
- draw_line(1,2,61,colors.green)
- draw_text(20,2, "Reaktor-System", colors.blue, colors.green)
- draw_line(1,3,61,colors.green)
- draw_text(2,5, "Energiestatus: "..percentage.."%",colors.white, colors.black)
- progress_bar(2,6,59,energyStored,maxEnergy,colors.red,colors.gray)
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement