Advertisement
magnasiefr

MFE OpenComputer

Oct 5th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.67 KB | None | 0 0
  1. local comp = require('component')
  2. local gpu = comp.gpu
  3.  
  4. if not comp.isAvailable("ic2_te_mfe") then
  5.   print("MFE don't found")
  6.   os.exit()
  7. end
  8.  
  9. local function getAllSpecificComponets(filter)
  10.   local tableObjects ={}
  11.   for address, componentType in comp.list(filter) do
  12.     table.insert(tableObjects, comp.proxy(address))
  13.   end
  14.   return tableObjects
  15. end
  16.  
  17. local mfe = getAllSpecificComponets('ic2_te_mfe')
  18. local capacity = mfe[1].getCapacity
  19.  
  20. if #mfe > 5 then
  21.   print("Too much MFE")
  22.   os.exit()
  23. end
  24.  
  25. local w, h = gpu.getResolution()
  26. gpu.fill(1, 1, w, h, " ")
  27. gpu.setBackground(0x000000)
  28. gpu.setForeground(0x669999)
  29. local a,b,c,d,e,f = 1,2,3,4,3,4
  30. for i = 1, #mfe do
  31.   gpu.set(3, a, "MFE "..i.." :")
  32.   gpu.set(1, b, " ┌────────────────────────────────────┐ ")
  33.   gpu.set(1, c, " │")                  gpu.set(39, e, "│ ")
  34.   gpu.set(1, d, " └────────────────────────────────────┘ ")
  35.   a=a+5 b=b+5 c=c+5 d=d+5 e=e+5
  36.   if i ~= #mfe then f=f+5 end
  37. end
  38. gpu.setResolution(44, f)
  39. gpu.setForeground(0xFF9900)
  40.  
  41. local stored,procent,progress = 0,0,0
  42. local a,b,c,d = 1,3,3,4
  43. while true do
  44.   for i = 1, #mfe do
  45.     stored = mfe[i].getEnergy
  46.     procent = math.ceil(stored()/capacity()*100)
  47.     progress = math.ceil(procent/100*34)
  48.     gpu.set(14, a, stored().." Eu on "..capacity())
  49.     gpu.set(40, b, procent.."% ")
  50.     d = 4
  51.     for i = 1, progress do
  52.       if d < 38 then
  53.         gpu.set(d, c, "█ ")
  54.       end
  55.       d = d + 1
  56.     end
  57.     a=a+5 b=b+5 c=c+5
  58.     if i == #mfe then a,b,c = 1,3,3 end
  59.   end
  60. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement