Clem105

Test

May 24th, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.95 KB | None | 0 0
  1.    
  2.  
  3.     local Data = {}
  4.     local bridgeSide = "top"
  5.     local modemSide = "left"
  6.     local bridge = peripheral.wrap(bridgeSide)
  7.     local Width = 50
  8.     local Color1 = {}
  9.     local Color2 = {}
  10.     local DefaultColor1 = 0x101010     
  11.     local DefaultColor2 = 0xCC1818
  12.     local Title = {}
  13.      
  14.     function FillData()
  15.             for i =1,#peripheral.getNames() do
  16.                     if  peripheral.getNames()[i] ~= modemSide and peripheral.getNames()[i] ~= bridgeSide then
  17.                             Data[i] = {}
  18.                             Data[i]["Side"] = peripheral.getNames()[i]
  19.                             Data[i]["Name"] = peripheral.getType(Data[i]["Side"])
  20.                             Data[i]["Capacity"] = peripheral.call(Data[i]["Side"],"getEUCapacity")
  21.                             Data[i]["Stored"] = peripheral.call(Data[i]["Side"],"getEUStored")
  22.                     end    
  23.             end
  24.     end
  25.      
  26.      
  27.            
  28.     function Middle(txt)
  29.             local f = (15+Width)/2
  30.             return f
  31.     end
  32.     function MaJ()
  33.             for i =1,#peripheral.getNames() do
  34.                     if  peripheral.getNames()[i] ~= modemSide and peripheral.getNames()[i] ~= bridgeSide then
  35.                             Barre[i].setWidth(Data[i]["Stored"]/Data[i]["Capacity"]*Width)
  36.                             Name[i].setText(Title[i+2])
  37.                             Name[i].setX(Middle(Name[i].getText()))
  38.                             Pourcent[i].setText(math.floor(Data[i]["Stored"]/Data[i]["Capacity"]*100))
  39.                             Pourcent[i].setX(Middle(Pourcent[i].getText()))        
  40.                     end
  41.             end
  42.     end
  43.      
  44.     --**********************
  45.     --*****MainProgramm*****
  46.     --**********************
  47.      
  48.      
  49.             local y = 15
  50.             Barre = {}
  51.             Name = {}
  52.             Pourcent = {}
  53.             for i =1,#peripheral.getNames() do
  54.                     if  peripheral.getNames()[i] ~= modemSide and peripheral.getNames()[i] ~= bridgeSide then
  55.                             print(i)
  56.                             if Color1[i] == nil then
  57.                                 Color1[i] = DefaultColor1
  58.                                 print("Color1")
  59.                             end
  60.                             if Color2[i] == nil then
  61.                                 Color2[i] = DefaultColor2
  62.                                 print("Color2")
  63.                             end
  64.                             if Title[i] == nil then
  65.                                 Title[i] = peripheral.getType(peripheral.getNames()[i])
  66.                             end
  67.                             bridge.addGradientBox(15,y,Width+2,18,0x000000,1,0x101010,0.75,2)
  68.                             Barre[i] = bridge.addGradientBox(16,y+1,0,16,Color1[i],0.5,Color2[i],0.75,2)
  69.                             Name[i] = bridge.addText(0,y+10," ",0xFFFFFF)
  70.                             Name[i].setScale(0.8)
  71.                             Pourcent[i] = bridge.addText(0,y+7," ",0xFFFFFF)
  72.                             Pourcent[i].setScale(0.5)
  73.                             y = y+24
  74.                     end
  75.             end
  76.      
  77.     while true do
  78.             FillData()
  79.             MaJ()
  80.             os.sleep(2)
  81.     end
Advertisement
Add Comment
Please, Sign In to add comment