Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inGate = peripheral.wrap("flux_gate_1") -- Edit to the name of your input flux gate.
- outGate = peripheral.wrap("flux_gate_0") -- Edit to the name of your output flux gate.
- otherComputerId = 15 -- Change this number to the other computers' ID. You can get the ID by typing "id" into the terminal.
- reactor = peripheral.find("draconic_reactor")
- if reactor == nil then
- print("No reactor found!")
- return
- end
- info = {}
- local modemCount = 0
- for i,v in pairs(redstone.getSides()) do
- if peripheral.getType(v) == "modem" then
- rednet.open(v)
- modemCount = modemCount + 1
- end
- end
- if modemCount < 2 then
- print("You need at least one wireless/ender modem and another wired modem to connect the flux gates with.")
- return
- end
- local temp
- local shield
- local sat
- local fuel
- local status
- local inputRate
- local inputMult = 1.015
- local outputRate
- local targetTemp = 8000
- local outputMult = 3
- safetyOverride = false
- function mainStuff()
- while true do
- info = reactor.getReactorInfo()
- temp = info.temperature
- shield = math.ceil(info.fieldStrength / info.maxFieldStrength * 1000) / 1000
- sat = math.ceil(info.energySaturation / info.maxEnergySaturation * 1000) / 1000
- fuel = math.ceil(info.fuelConversion / info.maxFuelConversion * 10000) / 10000
- status = info.status
- rednet.send(otherComputerId, info)
- -- Get the output RF/t speed
- if shield < 0.02 then
- outputMult = 10
- elseif shield >= 0.02 and shield < 0.1 then
- outputMult = 7
- elseif shield >= 0.1 and shield < 0.4 then
- outputMult = 3.5
- else
- outputMult = 2
- end
- if temp <= targetTemp + 1 then
- outputRate = info.generationRate * outputMult * (1.1 - (temp / targetTemp))
- else
- outputRate = info.generationRate * 0.96
- end
- inputRate = info.fieldDrainRate * inputMult * (1 - shield)
- safetyCheck()
- if status == "running" and fuel > 0.8 then
- reactor.stopReactor()
- elseif status == "running" and safetyOverride == false then
- if safetyOverride == false then
- inGate.setSignalLowFlow(inputRate)
- outGate.setSignalLowFlow(outputRate)
- end
- elseif status == "cooling" or coreStatus == "stopping" then
- outGate.setSignalLowFlow(0)
- if temp < 2000 then
- inGate.setSignalLowFlow(0)
- else
- inGate.setSignalLowFlow(500000)
- end
- elseif status == "warming_up" then
- inGate.setSignalLowFlow(1000000)
- outGate.setSignalLowFlow(0)
- end
- sleep(0)
- end
- end
- function safetyCheck()
- if ( shield < 0.005 or temp >= 8200 or sat <= .05 ) then
- if safetyOverride == false and temp >= 2000 then
- safetyOverride = true
- end
- if temp >= 2000 then
- inGate.setSignalLowFlow(500000)
- outGate.setSignalLowFlow(0)
- end
- else
- if (shield > .1 and temp < 8000 and safetyOverride == true ) then
- safetyOverride = false
- end
- end
- if temp >= 2500 and status == "running" then
- reactor.setFailSafe(true)
- elseif status == "warming_up" then
- reactor.setFailSafe(false)
- end
- return
- end
- function redNetReceive()
- while true do
- id, msg = rednet.receive()
- if id == otherComputerId then
- if msg == "chargeReactor" and (info.status == "cold" or info.status == "cooling") then
- reactor.chargeReactor()
- end
- if msg == "activateReactor" and (info.status == "warming_up" or info.status == "stopping") and info.temperature >= 2000 then
- reactor.activateReactor()
- end
- if msg == "stopReactor" and (info.status == "warming_up" or info.status == "running") then
- reactor.stopReactor()
- end
- end
- sleep(0)
- end
- end
- parallel.waitForAll(mainStuff, redNetReceive)
- --setFailSafe(bool)
- -- cold warming_up running stopping cooling
- -- beyond_hope
Add Comment
Please, Sign In to add comment