Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local gpu = component.gpu
- gpu.setResolution(160,50)
- local function bargraph_horizontal(x,y,w,h,color,fond,max,mesure)
- gpu.setBackground(fond)
- gpu.fill(x,y,w,h)
- nw = math.floor(mesure/(max*w))
- gpu.setBackground(color)
- gpu.fill(x,y,nw,h)
- end
- local function bargraph_vertical(x,y,w,h,color,fond,max,mesure)
- gpu.setBackground(fond)
- gpu.fill(x,y,w,h)
- nh = math.floor(mesure/(max*h))
- ny = math.floor(y + h - nh)
- gou.setBackground(color)
- gpu.fill(x,ny,w,nh)
- end
- local function affiche()
- gpu.setBackground(0xFFFFFF)
- e = epaisseur
- gpu.fill(1,1,160,1," ")
- gpu.fill(1,50,160,1," ")
- gpu.fill(1,1,1,50," ")
- gpu.fill(160,1,1,50," ")
- gpu.fill(40,1,1,50," ")
- gpu.fill(80,1,1,50," ")
- gpu.fill(120,1,1,50," ")
- gpu.fill(1,25,120,1," ")
- --les cases font du 38x23
- end
- local function rack1()
- gtank1 = component.get("f81b")
- tank1 = component.proxy(gtank1)
- mesure1 = tank1.getEnergyStored()
- max1 = tank1.getMaxEnergyStored()
- bargraph_horizontal(5,5,31,10,0x99FF00,0x5A5A5A,max1,mesure1)
- pourcentage = math.floor(100*mesure1/max1)
- gpu.set(19,21,..pourcentage.."%")
- end
- local function rack2()
- gtank1 = component.get("f74d")
- tank1 = component.proxy(gtank1)
- mesure2 = tank1.getEnergyStored()
- max2 = tank1.getMaxEnergyStored()
- bargraph_horizontal(44,5,31,10,0x99FF00,0x5A5A5A,max2,mesure2)
- pourcentage = math.floor(100*mesure2/max2)
- gpu.set(58,21,..pourcentage.."%")
- end
- local function rack3()
- gtank1 = component.get("6fba")
- tank1 = component.proxy(gtank1)
- mesure3 = tank1.getEnergyStored()
- max3 = tank1.getMaxEnergyStored()
- bargraph_horizontal(83,5,31,10,0x99FF00,0x5A5A5A,max3,mesure3)
- pourcentage = math.floor(100*mesure3/max3)
- gpu.set(97,21,..pourcentage.."%")
- end
- local function rack4()
- gtank1 = component.get("dcda")
- tank1 = component.proxy(gtank1)
- mesure4 = tank1.getEnergyStored()
- max4 = tank1.getMaxEnergyStored()
- bargraph_horizontal(5,29,31,10,0x99FF00,0x5A5A5A,max4,mesure4)
- pourcentage = math.floor(100*mesure4/max4)
- gpu.set(19,45,..pourcentage.."%")
- end
- local function rack5()
- gtank1 = component.get("34a5")
- tank1 = component.proxy(gtank1)
- mesure5 = tank1.getEnergyStored()
- max5 = tank1.getMaxEnergyStored()
- bargraph_horizontal(44,29,31,10,0x99FF00,0x5A5A5A,max5,mesure5)
- pourcentage = math.floor(100*mesure5/max5)
- gpu.set(58,45,..pourcentage.."%")
- end
- local function rack6()
- gtank1 = component.get("738e")
- tank1 = component.proxy(gtank1)
- mesure6 = tank1.getEnergyStored()
- max6 = tank1.getMaxEnergyStored()
- bargraph_horizontal(83,29,31,10,0x99FF00,0x5A5A5A,max6,mesure6)
- pourcentage = math.floor(100*mesure6/max6)
- gpu.set(97,45,..pourcentage.."%")
- end
- local function total()
- mesuretotale = mesure1 + mesure2 + mesure3 + mesure4 + mesure5 + mesure6
- maxtotal = max1 + max2 + max3 + max4 + max5 + max6
- bargraph_vertical(128,5,27,36,0xCC6D00,0x5A5A5A,maxtotal,mesuretotale)
- pourcentage = math.floor(100*mesuretotale/maxtotal)
- gpu.set(139,45,..pourcentage.."%")
- end
- term.clear
- while true do
- affiche()
- rack1()
- rack2()
- rack3()
- rack4()
- rack5()
- rack6()
- total()
- os.sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement