Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local term = require("term")
- local component = require("component")
- -------------------------------------------------
- -------These can be configured as you need-------
- -- The percentage of steam you wish to hold in the tank.
- -- Range 1 - 99
- steamTarget = 70
- -- The amount of time the program rests before begining again.
- -- Lower than 0.2 is not advised.
- loopSleep = 0.2
- -- How many seconds before the turbine is checked for required adjustments.
- turbineTimer = 10
- -- The amount of steam the turbine should allow at the start.
- -- Range: 0 - 2000.
- flowStart = 0
- -- The amount the reactor rods are inserted at the start. Higher values equal less steam.
- -- Range 0 - 100.
- rodStart = 100
- -- The increase or decrease of steam flowing into the turbine.
- -- A higher value increase response to energy draw, but is harder to stabalise.
- flowUpDown = 1
- -- The percentage of the turbine buffer that will trigger activation/deactivation.
- -- Going lower than 30 (or outside the range) is not advised.
- -- Range 1 - 99
- tBuffer = 50
- -----Changing the rest can break the program-----
- -------------------------------------------------
- reactor = component.br_reactor
- turbine = component.br_turbine
- reactor.setActive(true)
- turbine.setActive(true)
- turbine.setFluidFlowRateMax(flowStart)
- reactor.setAllControlRodLevels(rodStart)
- function turbineCheck ()
- if turbine.getEnergyStored() >= (tBuffer * 10000) then
- turbine.setActive(false)
- if turbine.getRotorSpeed() < 1901 then
- turbine.setFluidFlowRateMax(turbine.getFluidFlowRateMax()-flowUpDown)
- elseif turbine.getRotorSpeed() >= 1901 then
- turbine.setFluidFlowRateMax(turbine.getFluidFlowRateMax()-flowUpDown)
- end
- elseif turbine.getEnergyStored() < (tBuffer * 10000) then
- turbine.setActive(true)
- if turbine.getRotorSpeed() < 1901 then
- if turbine.getFluidFlowRateMax() <= (turbine.getFluidFlowRateMaxMax()-flowUpDown) then
- turbine.setFluidFlowRateMax(turbine.getFluidFlowRateMax()+flowUpDown)
- else
- turbine.setFluidFlowRateMax(2000)
- end
- elseif turbine.getRotorSpeed() > 1901 then
- turbine.setActive(false)
- end
- end
- end
- function reactorCheck ()
- if reactor.getHotFluidAmount() < 7000 then
- if reactor.getControlRodLevel(0) <= 100 then
- reactor.setAllControlRodLevels(reactor.getControlRodLevel(0)-1)
- reactor.setActive(true)
- end
- elseif reactor.getHotFluidAmount() > 7000 then
- if reactor.getControlRodLevel(0) >= 0 then
- reactor.setAllControlRodLevels(reactor.getControlRodLevel(0)+1)
- reactor.setActive(false)
- end
- end
- end
- i = 1
- while true do
- if math.ceil(i) == 0 then
- turbineCheck()
- reactorCheck()
- i = turbineTimer
- elseif i < turbineTimer then
- reactorCheck()
- end
- term.clear()
- print("Turbine Output: "..math.ceil(turbine.getEnergyProducedLastTick()))
- print("Turbine Buffer: "..turbine.getEnergyStored())
- print("Reactor Rods at "..reactor.getControlRodLevel(0))
- steamTank = math.ceil(reactor.getHotFluidAmount() / (reactor.getHotFluidAmountMax() / 100))
- print("Steam tank "..steamTank.."% full")
- i = i - loopSleep
- if math.ceil(i) <= 0 then
- print("Turbine check in: 0")
- else
- print("Turbine check in: "..math.ceil(i))
- end
- print("Reactor Producing: "..reactor.getHotFluidProducedLastTick())
- print("Turbine Accepting: "..turbine.getFluidFlowRateMax())
- os.sleep(loopSleep)
- end
Advertisement
Add Comment
Please, Sign In to add comment