Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReactorInfo={}
- local Temp, FS, FSM, ES, ESM, FC, FCM, FCR, GR, FDR, ST, SHF, SLF
- local Temp1,ES1,FS1,Time, globalTime=0,0,0,0,0
- local Reactor=peripheral.wrap("top")
- local FluxGateOut=peripheral.wrap("back")
- local FluxgateIn=peripheral.wrap("bottom")
- while true do
- ReactorInfo=Reactor.getReactorInfo()
- for a,b in pairs(ReactorInfo) do
- if a=="status" then ST=b
- elseif a=="fieldStrength" then FS=b
- elseif a=="maxFieldStrength" then FSM=b
- elseif a=="energySaturation" then ES=b
- elseif a=="maxEnergySaturation" then ESM=b
- elseif a=="fuelConversion" then FC=b
- elseif a=="maxFuelConversion" then FCM=b
- elseif a=="fuelConversionRate" then FCR=b
- elseif a=="generationRate" then GR=b
- elseif a=="fieldDrainRate" then FDR=b
- elseif a=="temperature" then Temp=b
- end
- end
- SHF=FluxGateOut.getSignalHighFlow()
- SLF=FluxgateIn.getSignalLowFlow()
- if ST=="offline" then
- if FC/FCM<0.2 then
- Reactor.chargeReactor()
- end
- elseif ST=="charging" then
- FluxgateIn.setSignalLowFlow(1000000)
- elseif ST=="charged" then
- FluxgateIn.setSignalLowFlow(50000)
- FluxGateOut.setSignalHighFlow(10000)
- Reactor.activateReactor()
- elseif ST=="online" then
- if (Temp>8000 or FS/FSM<0.2 or ES/ESM<0.1) then --emergency shut down output
- redstone.setOutput("back",false)
- FluxGateOut.setSignalLowFlow(0)
- FluxGateOut.setSignalHighFlow(SHF*0.95)
- if FS/FSM<0.2 then FluxgateIn.setSignalLowFlow(SLF*1.5+1000) end
- elseif (Temp<7500 and FS/FSM>0.25 and ES/ESM>0.25) then
- redstone.setOutput("back",true)
- end
- if (((Temp<7500 and Temp-Temp1<50) or (Temp<5000 and Temp-Temp1<1000)) and Time==10) then
- if ES/ESM>0.99 then
- FluxGateOut.setSignalHighFlow(10000)
- elseif ((ES/ESM>0.6) and ((ES-ES1)/ESM>-0.05)) then --(-0.5%/s)
- FluxGateOut.setSignalHighFlow(SHF*(1+2/(SHF^0.2)))
- print("ES1:"..((ES-ES1)/ESM*10).."%")
- elseif ((ES/ESM>0.15) and ((ES-ES1)/ESM>-0.01)) then --(-0.1%/s)
- FluxGateOut.setSignalHighFlow(SHF*(1+2/(SHF^0.5)))
- print("ES2:"..((ES-ES1)/ESM*10).."%")
- elseif ES/ESM>0.1 and ES/ESM<0.15 then
- FluxGateOut.setSignalHighFlow(SHF*(1+(ES-ES1)/ESM))
- print("ES3 *"..(ES-ES1)/ESM)
- end
- if FS/FSM>0.99 then
- FluxgateIn.setSignalLowFlow(2000)
- elseif (FS/FSM>0.6 and (FS-FS1)/FSM>-0.05) then --(-0.5%/s)
- FluxgateIn.setSignalLowFlow(SLF*0.95)
- print("FS1:"..((FS-FS1)/FSM*10).."%")
- elseif (FS/FSM>0.3 and (FS-FS1)/FSM>-0.01) then --(-0.1%/s)
- FluxgateIn.setSignalLowFlow(SLF*0.98)
- print("FS2:"..((FS-FS1)/FSM*10).."%")
- elseif FS/FSM>0.25 and FS/FSM<0.3 then
- FluxgateIn.setSignalLowFlow(SLF*(1-(FS-FS1)/FSM/10))
- print("FS3 *"..(FS-FS1)/FSM/10)
- end
- end
- if Temp>7000 and Temp-Temp1>10 then
- FluxGateOut.setSignalHighFlow(SHF*0.99)
- print("T1")
- elseif Temp>7500 and Temp-Temp1>5 then
- FluxGateOut.setSignalHighFlow(SHF*0.99)
- print("T2")
- elseif Temp>7800 and Temp-Temp1>0 then
- FluxGateOut.setSignalHighFlow(SHF*0.95)
- print("T3")
- end
- if ((ES-ES1)/ESM<-0.01 and ES/ESM<0.25) then -- (-0.5%/s)
- FluxGateOut.setSignalHighFlow(SHF*0.98)
- print("ES4:"..((ES-ES1)/ESM*50).."%")
- end
- if ((FS-FS1)/FSM<-0.004 and FS/FSM<0.3) or ((FS-FS1)/FSM<-0 and FS/FSM<0.25) then -- (-0.2%/s , 0%)
- FluxgateIn.setSignalLowFlow(SLF*1.1)
- print("FS4:"..((FS-FS1)/FSM*50).."%")
- end
- if FC/FCM>0.9 then --90% Fuel is consumed ---> Shut down
- redstone.setOutput("back",false)
- FluxGateOut.setSignalLowFlow(0)
- Reactor.stopReactor()
- end
- Temp1=Temp
- ES1=ES
- FS1=FS
- end
- if Time==10 then Time=0 end
- Time=Time+2
- print("............."..globalTime.."............")
- globalTime=globalTime+2
- sleep(2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement