Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- term.setCursorPos(1,1)
- print("Executing Reactor Statistics...")
- mon = peripheral.wrap("top")
- reactor = peripheral.wrap("BigReactors-Reactor_0")
- function explode(d,p)
- local t, ll
- t={}
- ll=0
- if(#p == 1) then return {p} end
- while true do
- l=string.find(p,d,ll,true) -- find the next d in the string
- if l~=nil then -- if "not not" found then..
- table.insert(t, string.sub(p,ll,l-1)) -- Save it in our array.
- ll=l+1 -- save just after where we found it for searching next time.
- else
- table.insert(t, string.sub(p,ll)) -- Save what's left in our array.
- break -- Break at end, as it should be, according to the lua manual.
- end
- end
- return t
- end
- while true do
- mon.clear()
- mon.setCursorPos(5,1)
- mon.write("---------------------")
- mon.setCursorPos(5,2)
- mon.write("- Base Power -")
- mon.setCursorPos(5,3)
- mon.write("---------------------")
- -- Reactor Status
- mon.setCursorPos(5,4)
- mon.write("- Status:")
- if reactor.getActive() then
- mon.setTextColor(colors.green)
- mon.write(" Online")
- mon.setTextColor(colors.white)
- mon.write(" -")
- else
- mon.setTextColor(colors.red)
- mon.write(" Offline")
- mon.setTextColor(colors.white)
- mon.write(" -")
- end
- -- Fuel Reactivity
- mon.setCursorPos(5,5)
- local reacSplit = explode(".", tostring(reactor.getFuelReactivity()))
- mon.write("- Reactivity: ")
- mon.setTextColor(colors.yellow)
- mon.write(reacSplit[1])
- mon.setTextColor(colors.white)
- if string.len(reacSplit[1]) == 3 then
- mon.write(" -")
- else
- mon.write(" -")
- end
- -- Fuel Temperature
- mon.setCursorPos(5,6)
- mon.write("- Fuel Temp: ")
- ftSplit = explode(".", tostring(reactor.getFuelTemperature()))
- mon.setTextColor(colors.red)
- mon.write(ftSplit[1])
- mon.setTextColor(colors.white)
- if string.len(ftSplit[1]) == 4 then
- mon.write(" -")
- elseif string.len(ftSplit[1]) == 3 then
- mon.write(" -")
- elseif string.len(ftSplit[1]) == 2 then
- mon.write(" -")
- else
- mon.write(" -")
- end
- -- Case Temperature
- mon.setCursorPos(5,7)
- mon.write("- Case Temp: ")
- ctSplit = explode(".", tostring(reactor.getCasingTemperature()))
- mon.setTextColor(colors.red)
- mon.write(ctSplit[1])
- mon.setTextColor(colors.white)
- if string.len(ctSplit[1]) == 4 then
- mon.write(" -")
- elseif string.len(ctSplit[1]) == 3 then
- mon.write(" -")
- elseif string.len(ctSplit[1]) == 2 then
- mon.write(" -")
- else
- mon.write(" -")
- end
- -- RF/T
- mon.setCursorPos(5,8)
- mon.write("- Energy /t: ")
- ept = explode(".", tostring(reactor.getEnergyProducedLastTick()))
- mon.setTextColor(colors.orange)
- mon.write(ept[1])
- mon.setTextColor(colors.white)
- if string.len(ept[1]) == 4 then
- mon.write(" -")
- elseif string.len(ept[1]) == 3 then
- mon.write(" -")
- elseif string.len(ept[1]) == 2 then
- mon.write(" -")
- else
- mon.write(" -")
- end
- -- Complete Stats
- mon.setCursorPos(5,9)
- mon.write("---------------------")
- -- Yield to other processes
- sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement