Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local m=infutil.wrap("monitor")
- local re=infutil.wrap("generator")
- m.setTextScale(0.5)
- local Mx,My=m.getSize()
- local Cx,Cy=math.ceil(Mx/2),math.ceil(My/2)
- m.setCursorPos(Cx-5,2)
- m.write("Main power")
- m.setCursorPos(Cx-4,8)
- m.write("Reactor")
- while true do
- local st,mx=0,0
- do -- Main power
- for k,v in pairs(peripheral.getNames()) do
- if peripheral.getType(v)=="batbox" then
- st=st+peripheral.call(v,"getStored")
- mx=mx+peripheral.call(v,"getCapacity")
- end
- end
- st=math.min(st,mx)
- local i=math.ceil((st/mx)*(Mx-3))
- for l=4,6 do
- m.setBackgroundColor(colors.green)
- m.setCursorPos(2,l)
- m.write(string.rep(" ",i))
- m.setBackgroundColor(colors.red)
- m.write(string.rep(" ",math.max(0,(Mx-3)-i)))
- end
- local t=(math.floor((st/mx)*1000)/10).."% ["..tostring(st):reverse():gsub("...","%1,"):reverse().."/"..tostring(mx):reverse():gsub("...","%1,"):reverse().." EU]"
- local n=math.max(0,i-(Cx-math.floor(#t/2))+2)
- m.setBackgroundColor(colors.green)
- m.setCursorPos(Cx-math.floor(#t/2),5)
- m.setTextColor(colors.black)
- m.write(t:sub(1,n))
- m.setBackgroundColor(colors.red)
- m.write(t:sub(n+1))
- end
- do -- Reactor
- m.setTextColor(colors.white)
- m.setBackgroundColor(colors.black)
- m.setCursorPos(2,10)
- m.clearLine()
- m.write("Status: ")
- if re.getOutput()~=0 then
- m.setTextColor(colors.green)
- m.write("ON")
- else
- m.setTextColor(colors.red)
- m.write("OFF")
- end
- m.setTextColor(colors.white)
- m.setCursorPos(2,11)
- m.clearLine()
- m.write("Cycle: ")
- local p=re.getStackInSlot(20)
- if re.getOutput()~=0 and p then
- local r=math.floor(p.dmg/8)
- local sc=tostring(math.floor(r%60))
- m.write((100-math.floor((p.dmg/10000)*1000)/10).."% ["..math.floor(r/60)..":"..string.rep("0",2-#sc)..sc.."]")
- else
- m.write("N/A")
- end
- end
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement