Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shell.run("clear")
- mon = peripheral.wrap("back")
- os.loadAPI("ocs/apis/sensor")
- sen = sensor.wrap("top")
- mon.clear()
- sTime = 1
- rs.setOutput("front",true)
- gx,gy = mon.getSize()
- function cbut(x,y,text,bcol,tcol)
- if bcol == nil then
- bcol = colors.black
- end
- if tcol == nil then
- tcol = colors.white
- end
- mon.setBackgroundColor(bcol)
- mon.setTextColor(tcol)
- mon.setCursorPos(x,y)
- mon.write(text)
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- end
- mon.setTextScale(0.5)
- while true do
- shell.run("clear")
- tab = {}
- n = 0
- s = sen.getTargets()
- for v, k in pairs(s) do
- if k.Name == "MFSU" then
- s1 = sen.getTargetDetails(v)
- tab[n] = {}
- tab[n]["Stored"] = s1.Stored
- tab[n]["Capacity"] = math.floor(s1.Capacity)
- tab[n]["Percent"] = math.floor(100 / s1.Capacity * s1.Stored,0)
- n = n +1
- end
- end
- mon.clear()
- print(#tab .. " MFSU's loaded")
- cbut(1,1,"ID")
- cbut(10,1,"Stored")
- cbut(22,1,"Capacity")
- cbut(33,1,"Percent")
- g = 0
- a = 0
- for i = 0 , #tab,1 do
- g = g + tab[i]["Capacity"]
- a = a + tab[i]["Stored"]
- if tab[i]["Percent"] == 100 then
- ttcol = colors.green
- elseif tab[i]["Percent"] < 100 and tab[i]["Percent"] > 50 then
- ttcol = colors.orange
- elseif tab[i]["Percent"] < 50 then
- ttcol = colors.red
- end
- cbut(1,i+3,string.format("%d",i+1),colors.black,ttcol)
- cbut(10,i+3,string.format("%d",tab[i]["Stored"]),colors.black,ttcol)
- cbut(20,i+3,"/", colors.black,ttcol)
- cbut(22,i+3,string.format("%d",tab[i]["Capacity"]),colors.black,ttcol)
- cbut(33,i+3,string.format("%d",tab[i]["Percent"]),colors.black,ttcol)
- if tab[i]["Percent"] < 100 then
- cbut(35,i+3," %",colors.black,ttcol)
- else
- cbut(36,i+3," %",colors.black,ttcol)
- end
- end
- i = 100 / g * a
- cbut(1,gy-1,"Sum:")
- cbut(10,gy-1,string.format("%d",a))
- cbut(20,gy-1,"/")
- cbut(22,gy-1,string.format("%d",g))
- cbut(33,gy-1,string.format("%d",i))
- if i < 100 then
- cbut(35,gy-1," %")
- else
- cbut(36,gy-1," %")
- end
- if i > 90 and i <= 100 then
- rs.setOutput("front",false)
- elseif i < 90 then
- rs.setOutput("front",true)
- end
- sleep(sTime)
- end
Add Comment
Please, Sign In to add comment