LivioBrunner

Energy Control

Nov 14th, 2013
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.20 KB | None | 0 0
  1. local nb = peripheral.wrap("left")
  2. local p = peripheral.wrap("right")
  3. local all = 0
  4. local mfsu = {0}
  5. local strom = {}
  6. local length = 100
  7. p.clear()
  8. function getAllEU()
  9.         local all = 0
  10.     for i = mfsu[1], tablelength(mfsu)+mfsu[1]-1 do
  11.         all = all + strom[i]
  12.     end
  13.     return all
  14. end
  15. function tablelength(T)
  16.   local count = 0
  17.   for _ in pairs(T) do count = count + 1 end
  18.   return count
  19. end
  20. function progressBarInit(left,top)
  21.    p.addBox(left,top,length + 20, 30, 0xE0E0E0, 0.3)
  22.    box = p.addBox(left +3,top + 15,length,5,0x000000,1)
  23.    box.setColor2(0x2ADEDE)
  24.    box.setGradient(2)
  25.    box1 = p.addBox(3,10,4,15,0xF22E2E,1)
  26.    text = p.addText(3,3 , "EU", 0x000000)
  27. end
  28. function progressBar(left,top)
  29. for i = mfsu[1], tablelength(mfsu)+mfsu[1]-1 do
  30.     EU = nb.callRemote("batbox_"..i, "getStored")
  31.     print(EU)
  32.     strom[i] = EU
  33.   end
  34.    red =  length / (tablelength(mfsu) * 10000000) * getAllEU()
  35.    box1.delete()
  36.    text.delete()
  37.    box1 = p.addBox(left + 3 + red - 2,top + 10,4,15,0xF22E2E,1)
  38.    text = p.addText(left + 3,top + 3 , getAllEU() .."/".. (tablelength(mfsu) * 10000000).."EU", 0x000000)
  39.    sleep(1)
  40. end
  41.  
  42.  
  43.  
  44. progressBarInit(0,0)
  45. while true do
  46.   progressBar(0,0)
  47. end
Advertisement
Add Comment
Please, Sign In to add comment