Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local emax=10000000
- local r
- local m1
- local m2
- local comp
- local nummon
- local mons ={}
- function findPer(s)
- local per = peripheral.getNames()
- local sameper = {}
- for k,v in pairs (per) do
- if (peripheral.getType(per[k])==s) then
- table.insert(sameper,v)
- --else print("Peripheral not Found")
- end
- end
- return sameper
- end
- function setupPer()
- local tr = unpack(findPer("BigReactors-Reactor"))
- local tm1,tm2 = unpack(findPer("monitor"))
- r = peripheral.wrap(tr)
- m1 = peripheral.wrap(tm1)
- m2 = peripheral.wrap(tm2)
- term.redirect(m2)
- comp = term.restore()
- term.restore()
- table.insert(mons,m1)
- table.insert(mons,m2)
- if m1 then
- m1.setTextScale(0.5)
- m1.clear()
- m1.setCursorPos(1,1)
- --term.redirect(m)
- end
- if m2 then
- m2.setTextScale(0.5)
- m2.clear()
- m2.setCursorPos(1,1)
- --term.redirect(m)
- end
- if r.nativeEPLT then
- r.getEnergyProducedLastTick = r.nativeEPLT
- end
- r.nativeEPLT = r.getEnergyProducedLastTick
- r.getEnergyProducedLastTick = function ()
- return math.floor(r.nativeEPLT()*100)/100
- end
- if r.nativeFT then
- r.getFuelTemperature = r.nativeFT
- end
- r.nativeFT = r.getFuelTemperature
- r.getFuelTemperature = function ()
- return math.floor(r.nativeFT()*100)/100
- end
- if r.nativeCT then
- r.getCasingTemperature = r.nativeCT
- end
- r.nativeCT = r.getCasingTemperature
- r.getCasingTemperature = function ()
- return math.floor(r.nativeCT()*100)/100
- end
- if r.nativeFCLT then
- r.getFuelConsumedLastTick = r.nativeFCLT
- end
- r.nativeFCLT = r.getFuelConsumedLastTick
- r.getFuelConsumedLastTick = function ()
- return math.floor(r.nativeFCLT()*1000)/1000
- end
- end
- getFuelEfficiency = function ()
- return math.floor (r.getEnergyProducedLastTick()/r.getFuelConsumedLastTick ())
- end
- getEnergyPercent = function()
- return math.floor(1000 * r.getEnergyStored() / emax)/10
- end
- function ft ()
- local d=os.day()
- local t=os.time()
- local h=math.floor(t)
- local m=math.floor((t-h)*60)
- return string.format("Day %d, %02d:%02d",d,h,m)
- end
- function Align(t)--aligns values to the right based on their length
- local strmax = 0
- for k,v in pairs(t) do
- if #v>strmax then strmax=#v
- end
- end
- return strmax
- end
- function Pad(s,n)
- local pad = n-#s
- return string.rep(" ",pad)..s
- end
- function centreText(s,m)
- local x,y = m.getSize()
- local cs = (x-#s)/2
- m.setCursorPos( cs,1)
- write(s.."\n")
- end
- function display()
- for _,val in pairs(mons) do
- term.redirect(val)
- term.clear()
- term.setCursorPos(1,1)
- --print("Reactor Status")
- centreText("Reactor Status",val)
- print(ft())
- local funcnames=
- {"Connected","Active","NumberOfControlRods","EnergyStored","EnergyPercent","FuelTemperature","CasingTemperature","FuelAmount","WasteAmount","FuelAmountMax","EnergyProducedLastTick","FuelConsumedLastTick","FuelEfficiency"}
- local funcs=
- {"Connected","Active","NumberOfControlRods","EnergyStored","FuelTemperature","CasingTemperature","FuelAmount","WasteAmount","FuelAmountMax","EnergyProducedLastTick","FuelConsumedLastTick"}
- local units={"","","","RF","%","C","C","mB","mB","mB","RF/t","mB/t","RF/mB"}
- local values={}
- for i=1,#funcs do
- values[i]=tostring(r["get"..funcs[i]]())
- end
- table.insert(values,5,tostring(getEnergyPercent()))
- table.insert(values,tostring(getFuelEfficiency()))
- local funcW = Align(funcnames)
- local valueW = Align(values)
- for k,v in pairs( funcnames ) do
- print(Pad(v,funcW)..": "..Pad(values[k],valueW).." "..units[k])
- end
- end
- end
- setupPer()
- while true do
- local e = r.getEnergyStored()
- local eper = math.floor(1000 * e / emax)/10
- local a=eper<100
- display()
- r.setAllControlRodLevels(eper)
- r.setActive(a)
- os.startTimer(0.8333334)
- local event,p1,p2,p3,p4,p5 = os.pullEvent()
- if event == "key" then
- m1.write("Exiting")
- m2.write("Exiting")
- break
- end
- end
- term.redirect(term.native)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement