Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local reactors = {}
- local turbines = {}
- for _, name in pairs(peripheral.getNames()) do
- if peripheral.getType(name) == "BigReactors-Reactor" then
- local wrapped = peripheral.wrap(name)
- if wrapped.isActivelyCooled() then
- table.insert(reactors, wrapped)
- end
- elseif peripheral.getType(name) == "BigReactors-Turbine" then
- local wrapped = peripheral.wrap(name)
- table.insert(turbines, wrapped)
- wrapped.setActive(true)
- wrapped.setFluidFlowRateMax(2000)
- wrapped.setVentOverflow(true)
- end
- end
- print("Reactors found : " .. #reactors)
- print("Turbines found : " .. #turbines)
- print("\n")
- -- Ensure program should succeed
- if #reactors == 0 then
- print("No Activly Cooled Reactors were found, Optimal Rod Level Finder will Fail.")
- print("\nPress Enter to exit...")
- read()
- if shell then
- shell.exit()
- end
- end
- local reactor = reactors[1]
- local TargetProduction = (2000 * #turbines) / #reactors
- if #turbines == 0 then
- print("No turbines detected, program will assume you want to power a single turbine")
- print("\nPress Enter to continue...")
- read()
- TargetProduction = 2000
- end
- print("This script will attempt find the optimal level for the control rods of 1 reactor. The optimal level is determined by the number of turbines and reactors you have.")
- print("It simply takes the number of turbines and devides by the number of reactors. If you have 2 turbines and 2 reactors then the Optimal steam output will be 2000mb for each reactor.")
- print("It only tests 1 reactor and assumes the others are built exactly the same.")
- print("\nPress Enter to proceed with the test...")
- read()
- print("Beginning Test...")
- sleep(4)
- -- Begin test
- local production = 0
- local rodLevels = 0
- -- Set Reactor Rod Level
- function SetRods(targetLevel)
- -- Ensure targetLevel is within spec
- if targetLevel < 0 or targetLevel > 100 then targetLevel = 99 end
- local controlRodsCount = reactor.getNumberOfControlRods()
- -- Calculate floor and ceiling values
- local floorLevel = math.floor(targetLevel)
- local ceilLevel = math.ceil(targetLevel)
- -- Calculate how many rods should be set to each level
- local remainder = (targetLevel - floorLevel) * controlRodsCount
- local ceilCount = math.floor(remainder)
- local floorCount = controlRodsCount - ceilCount
- -- Build the levels table
- local controlRodsLevels = {}
- for i = 0, (floorCount - 1) do
- controlRodsLevels[i] = floorLevel
- end
- for i = floorCount, (controlRodsCount - 1) do
- controlRodsLevels[i] = ceilLevel
- end
- -- Set control rods levels
- reactor.setControlRodsLevels(controlRodsLevels)
- end
- reactor.setAllControlRodLevels(95)
- reactor.setActive(true)
- print("Set all rod levels to 95")
- print("Waiting 12 seconds to stabilize...")
- sleep(12)
- production = reactor.getHotFluidProducedLastTick()
- print(production .. " of " .. TargetProduction .. " MB/t of steam")
- rodLevels = 100 - (TargetProduction / production)
- print(TargetProduction .. "/" .. production .. " = " .. rodLevels)
- print("Estimated Level: " .. rodLevels)
- print("Waiting 12 seconds to stabilize...")
- print("\nBeginning test loop...")
- while production > TargetProduction or production < TargetProduction - 200 do
- production = reactor.getHotFluidProducedLastTick()
- print(production .. " of " .. TargetProduction .. " MB/t of steam")
- rodLevels = 100 - (TargetProduction / production)
- print(TargetProduction .. "/" .. production .. " = " .. rodLevels)
- print("Estimated Level: " .. rodLevels)
- print("Waiting 12 seconds to stabilize...")
- sleep(12)
- end
- print("Final production: " .. production)
- print("Deactivating reactor... Done")
- reactor.setActive(false)
- print("\nOptimal fuel rod level for your Reactors: " .. rodLevels .. "%")
- print("\nPress Enter to exit...")
- read()
- if shell then
- shell.exit()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement