Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- modified to work with draconic rf storage (trying to determine actual 'gain' from reactor)
- --local stabilizer = peripheral.wrap("right")
- local storage = peripheral.find("draconic_rf_storage")
- local monitor = peripheral.wrap("bottom")
- local core = peripheral.wrap("right")
- local fluxgate = peripheral.find("flux_gate")
- local powerstate = 0
- term.redirect(monitor)
- local x=0
- local y=0
- local fieldStrengthPercent=0
- local lastFieldStrengthPercent
- local energySaturationPercent=0
- local lastEnergySaturationPercent=0 -- last energy saturation
- local ecrft=0 -- energy core rf per tick
- fluxgate.setOverrideEnabled(true)
- while true do
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.setTextColor(colors.white)
- --for key,value in pairs(storage) do
- --print("key: "..key..", value: "..value)
- --end
- --for _,method in pairs(storage) do
- y=x
- x=storage.getEnergyStored()
- --end
- local stab = core.getReactorInfo()
- --for _, method in pairs(stabilizer) do
- --print(method)
- --end
- powerstate=stab.status
- -- print(" status: "
- monitor.setCursorPos(15,1)
- print("status:")
- if powerstate=="online" then
- monitor.setTextColor(colors.green)
- else
- monitor.setTextColor(colors.red)
- end
- monitor.setCursorPos(23,1)
- print(powerstate)
- monitor.setTextColor(colors.white)
- -- print(" status: "..stab.status)
- print(" generationRate: "..stab.generationRate.." RF/t")
- print(" temperature: "..stab.temperature)
- print(" fieldStrength: "..stab.fieldStrength)
- print(" maxFieldStrength: "..stab.maxFieldStrength)
- print(" fieldDrainRate: "..stab.fieldDrainRate)
- print("Fuel Conversion Rate: "..stab.fuelConversionRate.." nb/t")
- print(" maxFuelConversion: "..stab.maxFuelConversion)
- local fuelConversionPercent=stab.fuelConversion*100/stab.maxFuelConversion
- print(" fuelConversion: "..stab.fuelConversion.."("..math.floor(fuelConversionPercent).."%)")
- lastEnergySaturationPercent=energySaturationPercent
- energySaturationPercent=stab.energySaturation*100/stab.maxEnergySaturation
- print(" energySaturation: "..stab.energySaturation.."("..math.floor(energySaturationPercent).."%) "..energySaturationPercent-lastEnergySaturationPercent)
- print(" maxEnergySaturation: "..stab.maxEnergySaturation)
- print(" fluxgate flow: "..fluxgate.getFlow())
- lastFieldStrengthPercent=fieldStrengthPercent
- fieldStrengthPercent=stab.fieldStrength*100/stab.maxFieldStrength
- print(" Cont. fieldStrength: "..math.floor(fieldStrengthPercent).."%".."("..fieldStrengthPercent-fieldStrengthPercent..")")
- if (lastEnergySaturationPercent<energySaturationPercent) then
- print("++++ Correcting")
- elseif (lastEnergySaturationPercent>energySaturationPercent) then
- print("!!!! Degrading")
- end
- -- print(" --- ")
- print(" Energy Core Storage: "..x)
- ecrft=((((x-y)/1000/1000)/2)/20) -- there are 20 ticks in a second so you /20 not multiple dufus
- print(" Energy Core RF/t: "..ecrft.."MRF/t"..", "..(x*100/2140000000000).."%")
- if (fieldStrengthPercent<51 or energySaturationPercent<51) then
- -- if it's < than some kill switch probably have it scram the reactor
- redstone.setOutput("top", not redstone.getOutput("top"))
- redstone.setOutput("back",false)
- -- move correcting/degrading message inside this loop
- -- its not really relevant when it's 'safe' over 51%
- end
- if (fieldStrengthPercent>51 and energySaturationPercent>51) then
- redstone.setOutput("top",false)
- redstone.setOutput("back",true) -- redstone.getOutput("top"))
- end
- -- Energy dump, if core>25% then
- -- and if net gain >100MRf/t
- -- (and less than say 1000 to prevent initialization issues)
- -- set fluxgate low flow to core net gain
- --if ecrft>100 and ecrft<1000 then
- if (x*100/2141200000000)>70 then
- -- fluxgate.setSignalLowFlow=ecrft
- -- setFlowOverride=ecrft
- -- print("Set flow to "..ecrft)
- --if ecrft>100 then
- -- not sure why but 1000 only seemed to reduce 'gain' by ~200k
- -- fluxgate.setFlowOverride(ecrft*4000)
- fluxgate.setFlowOverride(stab.generationRate-(stab.fieldDrainRate*2))
- -- end
- -- fluxgate.setSignalLowFlow=ecrft*1000
- -- fluxgate.setOverrideEnabled(true)
- else
- fluxgate.setFlowOverride(500000)
- end
- -- print("debug: ecrft="..ecrft..", %"..x*100/2141200000000)
- -- end
- --end
- sleep(2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement