Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local reactor
- local monitor
- local shutoff=50
- local sume=0
- local sumf=0
- local sumt=0
- local cyclee=0
- local cyclef=0
- local cyclet=0
- local cooldown=false
- function findDev (dType)
- local d
- for _,d in pairs(peripheral.getNames()) do
- if (peripheral.getType(d) == dType) then
- return peripheral.wrap(d)
- end
- end
- return nil, dType..": not found"
- end
- function setupDevs()
- reactor=findDev("BigReactors-Reactor")
- monitor=findDev("monitor")
- monitor.setTextScale(0.5)
- term.redirect(monitor)
- end
- function display()
- term.clear()
- term.setCursorPos(1,1)
- print("---------------------------------------------------------")
- print("Reactor Status | "..textutils.formatTime(os.time(),true))
- print("---------------------------------------------------------")
- print("Active | "..tostring(reactor.getActive()))
- print("EnergyStored (RF) | "..tostring(reactor.getEnergyStored()).." RF")
- print("FuelTemperature | "..tostring(math.floor(reactor.getFuelTemperature())).." C")
- print("CasingTemperature | "..tostring(math.floor(reactor.getCasingTemperature())).." C")
- print("FuelReactivity | "..tostring(math.floor(reactor.getFuelReactivity())).." %")
- print("EnergyProducedLastTick | "..tostring(math.floor(reactor.getEnergyProducedLastTick())).." RF/t")
- print("FuelConsumedLastTick | "..tostring(reactor.getFuelConsumedLastTick()).." mB/t")
- print("---------------------------------------------------------")
- print("TicksLastCycle | "..tostring(cyclet).." t")
- print("EnergyProducedLastCycle | "..tostring(cyclee).." kRF")
- print("FuelConsumedCycle | "..tostring(cyclef).." mB")
- print("EfficienyLastCycle | "..tostring(cyclee/cyclef).." kRF/mB")
- print("EnergyProducedPerTick | "..tostring(cyclee/cyclet).." kRF/t")
- print("FuelConsumedPerTick | "..tostring(cyclef/cyclet).." mB/t")
- print("---------------------------------------------------------")
- end
- function workReactor()
- local energy=reactor.getEnergyStored()
- local percent=math.floor(energy/100000)
- local active=percent<shutoff
- if (active and cooldown) then
- -- Turning reactor back on
- -- Perform calculations on last cycle
- cyclee=sume
- cyclef=sumf
- cyclet=sumt
- sume=0
- sumf=0
- sumt=0
- cooldown=false
- end
- if (not active and not cooldown) then
- -- Turning reactor off
- -- Going into cooldown phase
- cooldown=true
- end
- reactor.setAllControlRodLevels(percent)
- reactor.setActive(active)
- end
- function main()
- cooldown = not reactor.getActive()
- local tick=0
- while true do
- sume=sume+reactor.getEnergyProducedLastTick()/1000
- sumf=sumf+reactor.getFuelConsumedLastTick()
- sumt=sumt+1
- tick=tick+1
- if (tick == 20) then
- workReactor()
- display()
- tick=0
- end
- sleep(.05)
- end
- end
- setupDevs()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement