Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Data = {}
- local bridgeSide = "top"
- local modemSide = "left"
- local bridge = peripheral.wrap(bridgeSide)
- local Width = 50
- local Color1 = {}
- local Color2 = {}
- local DefaultColor1 = 0x101010
- local DefaultColor2 = 0xCC1818
- local Title = {}
- function FillData()
- for i =1,#peripheral.getNames() do
- if peripheral.getNames()[i] ~= modemSide and peripheral.getNames()[i] ~= bridgeSide then
- Data[i] = {}
- Data[i]["Side"] = peripheral.getNames()[i]
- Data[i]["Name"] = peripheral.getType(Data[i]["Side"])
- Data[i]["Capacity"] = peripheral.call(Data[i]["Side"],"getEUCapacity")
- Data[i]["Stored"] = peripheral.call(Data[i]["Side"],"getEUStored")
- end
- end
- end
- function Middle(txt)
- local f = (15+Width)/2
- return f
- end
- function MaJ()
- for i =1,#peripheral.getNames() do
- if peripheral.getNames()[i] ~= modemSide and peripheral.getNames()[i] ~= bridgeSide then
- Barre[i].setWidth(Data[i]["Stored"]/Data[i]["Capacity"]*Width)
- Name[i].setText(Title[i+2])
- Name[i].setX(Middle(Name[i].getText()))
- Pourcent[i].setText(math.floor(Data[i]["Stored"]/Data[i]["Capacity"]*100))
- Pourcent[i].setX(Middle(Pourcent[i].getText()))
- end
- end
- end
- --**********************
- --*****MainProgramm*****
- --**********************
- local y = 15
- Barre = {}
- Name = {}
- Pourcent = {}
- for i =1,#peripheral.getNames() do
- if peripheral.getNames()[i] ~= modemSide and peripheral.getNames()[i] ~= bridgeSide then
- print(i)
- if Color1[i] == nil then
- Color1[i] = DefaultColor1
- print("Color1")
- end
- if Color2[i] == nil then
- Color2[i] = DefaultColor2
- print("Color2")
- end
- if Title[i] == nil then
- Title[i] = peripheral.getType(peripheral.getNames()[i])
- end
- bridge.addGradientBox(15,y,Width+2,18,0x000000,1,0x101010,0.75,2)
- Barre[i] = bridge.addGradientBox(16,y+1,0,16,Color1[i],0.5,Color2[i],0.75,2)
- Name[i] = bridge.addText(0,y+10," ",0xFFFFFF)
- Name[i].setScale(0.8)
- Pourcent[i] = bridge.addText(0,y+7," ",0xFFFFFF)
- Pourcent[i].setScale(0.5)
- y = y+24
- end
- end
- while true do
- FillData()
- MaJ()
- os.sleep(2)
- end
Advertisement
Add Comment
Please, Sign In to add comment