Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------------
- -- Simple Draconic Reactor Control
- -- V2.48 Not tested Please use with Caution
- -- Made By Daz_X
- --------------------------------------------------
- --THIS IS STILL BEING TESTED DON'T USE!!
- --Works with(1 Ingot,)
- --Dont use this reactor with less than 1 ingot of awakened draconium.
- --Change the local variables to change how your reactor will run
- --Make sure you change the call to match which side the FluxGate and Reactor Stabilizer are on
- --Can not guarantee your safety if you exced the maximum amounts
- --Does not control the input of Energy to the containment Field that will have to be handled manually
- --From my testing it seems for every ingot's worth of fuel you need to have 5000 RF/t going into the Energy Injector ie 1 Ingot= 5000RF 1 block = 45000RF but to be safe add a couple thousand or not whatever just don't kill yourself doing so.
- local Issue = "None" -- Used to denote why the reactor ceased functioning (None-Nothing wrong) (Temperature-Temperature exceeded limit)
- --(Chaos-Levels of Chaos element exceeded limit)(Containment-Containment Field below limit)(Energy-Energy Saturation below limit)
- local Incar = 2000 --Reactor output increment amount (Default = 2000)(max Safe ~10000)
- local SafeTemp = 8000 --Maximum safe Reactor temperature (Default = 8000)(Safe ~8000)
- local SafeFuelCon = 95 --Maximum safe Fuel conversion amount (Default = 90%)(Safe ~95%)
- local SafeForce = 15 --Minimum Containment field Strength before Shutdown (Default = 15%)(Safe ~15%)
- local SafeEnergy = 15 --Minimum Energy Saturation Level before ShutDown (Default = 18%)(Safe~ 15%)
- local EnSatIn = 21 --Energy Saturation Level where the output will begin Increasing According to Incar (Default = 40%)(Safe ~30%)
- local EnSatOut = 19 --Energy Saturation Level where the output will begin Decreasing According to Icaar (Default = 28%)(Safe ~20%)
- ----------------------------------------------------------------------
- --Gets all the information about the reactor
- function Info()
- tbl = peripheral.call("back","getReactorInfo")
- for k, v in pairs (tbl) do
- if k == "temperature" then
- Temp = v
- end
- if k == "energySaturation" then
- EnergySat = v
- end
- if k == "fieldStrength" then
- FieldSt = v
- end
- if k == "generationRate" then
- RFpt = v
- end
- if k == "fuelConversion" then
- FuelCon = v
- end
- if k == "fuelConversionRateN" then
- FuelConR = v
- end
- if k == "maxFieldStrength" then
- MaxSt = v
- end
- if k == "maxEnergySaturation" then
- MaxEn = v
- end
- if k == "maxFuelConversion" then
- MaxCon = v
- end
- if k == "status" then
- Stat = v
- end
- end
- --------------------------------------------------
- --All the math that runs the reactor
- UnSat = EnergySat / MaxEn
- EnSat = UnSat * 100
- kRFpt = RFpt / 1000
- fuel = FuelCon / MaxCon
- FuelConv = fuel * 100
- FieldPc = FieldSt / MaxSt
- Force = FieldPc * 100
- MaxPow = MaxCon * 200
- PowInt = MaxCon * 28
- end
- --------------------------------------------------
- -- Emergency Shutdown rules
- function Safety()
- if Temp > SafeTemp then --If the Reactor exceeds the temperature safety limits, Reactor Shutdown will be initiated
- peripheral.call("back", "stopReactor")
- Issue = "Temperature"
- print("| REACTOR OVERHEATING")
- print("| REACTOR SHUTDOWN INITIATED")
- sleep(300)
- end
- if FuelConv >= SafeFuelCon then --If the amount of Chaos in the Reactor exceeds safety limits, Reactor Shutdown will be initiated
- peripheral.call("back", "stopReactor")
- Issue = "Chaos"
- print("| REACTOR FUEL EXPENDED")
- print("| REACTOR SHUTDOWN INITIATED")
- sleep(300)
- end
- if Stat == "online" then
- if FieldSt <= SafeForce then --If the Containment Field drops below the safety limits, Reactor Shutdown will be initiated
- peripheral.call("back", "stopReactor")
- Issue = "Containment"
- print("| REACTOR CONTAINMENT LOW")
- print("| REACTOR SHUTDOWN INITIATED")
- sleep(300)
- end
- if EnSat <= SafeEnergy then --If the Energy Buffer drops below the safety limits, Reactor Shutdown will be initiated
- peripheral.call("back", "stopReactor")
- Issue = "Energy"
- print("| REACTOR ENERGY LOW")
- print("| REACTOR SHUTDOWN INITIATED")
- sleep(300)
- end
- end
- end
- --------------------------------------------------
- --Power Output Regulation
- function Power()
- PowerGate = peripheral.call("left", "getSignalLowFlow")
- if EnSat > EnSatIn then
- if PowerGate >= MaxPow then
- PowerGate = MaxPow
- end
- if PowerGate < PowInt then
- PowerGate = PowInt
- end
- if Stat == "online" then
- if PowerGate < MaxPow then
- PowerGate = PowerGate + Incar
- end
- end
- -- print("| Output set to = ", PowerGate)
- peripheral.call("left", "setSignalLowFlow", PowerGate)
- end
- if EnSat < EnSatOut then
- if Stat == "online" then
- PowerGate = PowerGate - Incar
- end
- -- print("| Output set to = ", PowerGate)
- peripheral.call("left", "setSignalLowFlow", PowerGate)
- end
- end
- --------------------------------------------------
- --Information Printout
- function PrintOut()
- print()
- print("| Reactor Status = "..Stat)
- print("| Reactor temperature = "..Temp)
- print("| Energy saturation % = "..EnSat)
- print("| Field strength % = "..Force)
- print("| Chaos Level % = "..FuelConv)
- print("| ConvesionRate = "..FuelConR)
- print("| Energyproduction kRF/t = "..kRFpt)
- print("| Energy Output RF/t = "..PowerGate)
- print("| Current Issues = "..Issue)
- print("| Maximum Power = "..MaxPow)
- --print("| Starter Power = "..PowInt)
- end
- -----------------------------------------------------------------
- --Looping
- while true do
- Info()
- Safety()
- Power()
- PrintOut()
- sleep(5)
- Info()
- Safety()
- PrintOut()
- sleep(5)
- Info()
- Safety()
- PrintOut()
- sleep(5)
- Info()
- Safety()
- PrintOut()
- sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement