Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Hastwell's BigReactor Control Script
- -- aka "Hardcore/HC-NUKE"
- --
- -- Features:
- -- Slow, power-efficent recharge when draw is low (think overnight recharge)
- --
- local reactorMaxTemp = 200
- local reactorMinTemp = 180
- local periList = peripheral.getNames()
- local reactors = {}
- local debugMonitor = nil
- for i = 1, #periList do
- if peripheral.getType(periList[i]) == "BigReactors-Reactor" then
- reactor = peripheral.wrap(periList[i])
- print("Reactor "..(#reactors+1).." mounted")
- table.insert(reactors,reactor)
- elseif peripheral.getType(periList[i]) == "monitor" then
- debugMonitor = peripheral.wrap(periList[i])
- debugMonitor.setTextScale(0.6)
- end
- end
- function round(num, idp)
- local mult = 10^(idp or 0)
- return math.floor(num * mult + 0.5) / mult
- end
- local function setControlRodRelative(react, change)
- local effectiveLv = react.getControlRodLevel(1) + change
- if effectiveLv > 100 or effectiveLv < 0 then
- -- nothing to do here! *blasts off*
- else
- react.setAllControlRodLevels(effectiveLv)
- end
- end
- local function controlReactor(react)
- -- begin reactor control loop
- -- first, is it too hot? ramp it down!
- if react.getFuelTemperature() > reactorMaxTemp then
- setControlRodRelative(react, 1)
- elseif react.getFuelTemperature() < reactorMinTemp then
- setControlRodRelative(react, -1)
- end
- -- keep above 180c
- -- print reactor stats
- debugMonitor.clear()
- debugMonitor.setCursorPos(1,1)
- debugMonitor.write("HC-Nuke - Controlling Reactor")
- debugMonitor.setCursorPos(1,2)
- debugMonitor.write("Temps - Core "..math.floor(react.getFuelTemperature()).." Case "..math.floor(react.getCasingTemperature()))
- debugMonitor.setCursorPos(1,3)
- debugMonitor.write("Rods "..react.getControlRodLevel(1).."%")
- debugMonitor.setCursorPos(1,4)
- debugMonitor.write("Output "..math.floor(react.getEnergyProducedLastTick()).." MJ/t at "..round(react.getEnergyProducedLastTick()/react.getFuelConsumedLastTick(),3).." MJ/mB")
- end
- -- mainloop
- while true do
- for i = 1, #reactors do
- controlReactor(reactors[i])
- end
- os.sleep(0.4)
- end
Advertisement
Add Comment
Please, Sign In to add comment