Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[opencomputers progress bar mfsu by serafim
- pastebin.com/kyN49tte
- Получить заряд МФСУ и вывести на экран.
- От 1-го до 5-ти mfsu подключенных к
- ПК с помощью адаптера.
- ]]--
- local comp = require('component')
- local gpu = comp.gpu
- if not comp.isAvailable("mfsu") then
- print("Ошибка! >> mfsu не найден")
- os.exit()
- end
- local function getAllSpecificComponets(filter)
- local tableObjects ={}
- for address, componentType in comp.list(filter) do
- table.insert(tableObjects, comp.proxy(address))
- end
- return tableObjects
- end
- local mfsu = getAllSpecificComponets('mfsu')
- local capacity = mfsu[1].getCapacity
- if #mfsu > 5 then
- print("Ошибка! >> подключено больше 5 mfsu")
- os.exit()
- end
- local w, h = gpu.getResolution()
- gpu.fill(1, 1, w, h, " ")
- gpu.setBackground(0x000000)
- gpu.setForeground(0x669999)
- local a,b,c,d,e,f = 1,2,3,4,3,4
- for i = 1, #mfsu do
- gpu.set(3, a, "MFSU "..i.." :")
- gpu.set(1, b, " ┌────────────────────────────────────┐ ")
- gpu.set(1, c, " │") gpu.set(39, e, "│ ")
- gpu.set(1, d, " └────────────────────────────────────┘ ")
- a=a+5 b=b+5 c=c+5 d=d+5 e=e+5
- if i ~= #mfsu then f=f+5 end
- end
- gpu.setResolution(44, f)
- gpu.setForeground(0xFF9900)
- local stored,procent,progress = 0,0,0
- local a,b,c,d = 1,3,3,4
- while true do
- for i = 1, #mfsu do
- stored = mfsu[i].getStored
- procent = math.ceil(stored()/capacity()*100)
- progress = math.ceil(procent/100*34)
- gpu.set(14, a, stored().." Eu из "..capacity())
- gpu.set(40, b, procent.."% ")
- d = 4
- for i = 1, progress do
- if d < 38 then
- gpu.set(d, c, "█ ")
- end
- d = d + 1
- end
- a=a+5 b=b+5 c=c+5
- if i == #mfsu then a,b,c = 1,3,3 end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement