Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Super basic reactor and turbine control script
- turbine = peripheral.wrap("BiggerReactors_Turbine_0")
- reactor = peripheral.wrap("BiggerReactors_Reactor_0")
- -- Basically we just want to PID power to 0 by way of control rod insertion
- -- First, let's see what we've got...
- -- Reactor:
- -- ambientTemperature
- -- connected
- -- active
- -- setAllControlRodLevels
- -- battery
- -- fuelTemperature
- -- controlRodCount
- -- setActive
- -- fuelTank
- -- coolantTank
- -- apiVersion
- -- getControlRod
- -- stackTemperature
- -- casingTemperature
- -- Actually, I might want to PID the casingTemperature to a certain level instead
- -- Just below steam generation so I can easily add more
- -- That should be 373.15k
- -- Turbine:
- -- connected
- -- rotor
- -- battery
- -- fluidTank
- -- setActive
- -- setCoilEngaged
- -- apiVersion
- -- active
- -- coilEngaged
- reactor.setActive(true)
- while(true) do
- local targetTemp = 500
- local steamScalar = 1/10
- -- We might need to adjust this up for when we need steam
- targetTemp = targetTemp - ((turbine.fluidTank().input().amount()-(1800-turbine.rotor().RPM())*50) * steamScalar)
- print("Target temp: " .. targetTemp)
- local controlMult = 0.0001
- -- Now try to keep the turbine at 1800 rpm
- if turbine.rotor().RPM() > 1800 and turbine.active() then
- turbine.setActive(false)
- elseif turbine.rotor().RPM() < 1800 and not turbine.active() then
- turbine.setActive(true)
- end
- -- And turn on the coils when we need power
- if turbine.battery().stored() == turbine.battery().capacity() and turbine.coilEngaged() then
- turbine.setCoilEngaged(false)
- elseif turbine.battery().stored() < turbine.battery().capacity() and not turbine.coilEngaged() then
- turbine.setCoilEngaged(true)
- end
- if turbine.coilEngaged() then
- targetTemp = targetTemp*2 -- And go ham if it's on
- end
- local controlRodChange = (reactor.casingTemperature()-targetTemp) * controlMult
- reactor.setAllControlRodLevels(reactor.getControlRod(0).level()+controlRodChange)
- print("Control rod change: " .. controlRodChange)
- print("RFT: " .. turbine.battery().producedLastTick())
- sleep(0.01)
- end
Advertisement
Add Comment
Please, Sign In to add comment