Advertisement
TIIITAN

Capacitor v1.0

Jul 21st, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.42 KB | None | 0 0
  1. local component = require("component")
  2.  
  3. local gpu = component.gpu
  4. gpu.setResolution(160,50)
  5.  
  6. local function bargraph_horizontal(x,y,w,h,color,fond,max,mesure)
  7.     gpu.setBackground(fond)
  8.     gpu.fill(x,y,w,h)
  9.     nw = math.floor(mesure/(max*w))
  10.     gpu.setBackground(color)
  11.     gpu.fill(x,y,nw,h)
  12.    
  13. end
  14.  
  15. local function bargraph_vertical(x,y,w,h,color,fond,max,mesure)
  16.     gpu.setBackground(fond)
  17.     gpu.fill(x,y,w,h)
  18.     nh = math.floor(mesure/(max*h))
  19.     ny = math.floor(y + h - nh)
  20.     gou.setBackground(color)
  21.     gpu.fill(x,ny,w,nh)
  22. end
  23.  
  24. local function affiche()
  25.     gpu.setBackground(0xFFFFFF)
  26.     e = epaisseur
  27.     gpu.fill(1,1,160,1," ")
  28.     gpu.fill(1,50,160,1," ")
  29.     gpu.fill(1,1,1,50," ")
  30.     gpu.fill(160,1,1,50," ")
  31.     gpu.fill(40,1,1,50," ")
  32.     gpu.fill(80,1,1,50," ")
  33.     gpu.fill(120,1,1,50," ")
  34.     gpu.fill(1,25,120,1," ")
  35.    
  36.     --les cases font du 38x23
  37.    
  38. end
  39.  
  40. local function rack1()
  41.     gtank1 = component.get("f81b")
  42.     tank1 = component.proxy(gtank1)
  43.     mesure1 = tank1.getEnergyStored()
  44.     max1 = tank1.getMaxEnergyStored()
  45.     bargraph_horizontal(5,5,31,10,0x99FF00,0x5A5A5A,max1,mesure1)
  46.     pourcentage = math.floor(100*mesure1/max1)
  47.     gpu.set(19,21,..pourcentage.."%")
  48.    
  49. end
  50.  
  51. local function rack2()
  52.     gtank1 = component.get("f74d")
  53.     tank1 = component.proxy(gtank1)
  54.     mesure2 = tank1.getEnergyStored()
  55.     max2 = tank1.getMaxEnergyStored()
  56.     bargraph_horizontal(44,5,31,10,0x99FF00,0x5A5A5A,max2,mesure2)
  57.     pourcentage = math.floor(100*mesure2/max2)
  58.     gpu.set(58,21,..pourcentage.."%")
  59.    
  60. end
  61.  
  62. local function rack3()
  63.     gtank1 = component.get("6fba")
  64.     tank1 = component.proxy(gtank1)
  65.     mesure3 = tank1.getEnergyStored()
  66.     max3 = tank1.getMaxEnergyStored()
  67.     bargraph_horizontal(83,5,31,10,0x99FF00,0x5A5A5A,max3,mesure3)
  68.     pourcentage = math.floor(100*mesure3/max3)
  69.     gpu.set(97,21,..pourcentage.."%")
  70.    
  71. end
  72.  
  73. local function rack4()
  74.     gtank1 = component.get("dcda")
  75.     tank1 = component.proxy(gtank1)
  76.     mesure4 = tank1.getEnergyStored()
  77.     max4 = tank1.getMaxEnergyStored()
  78.     bargraph_horizontal(5,29,31,10,0x99FF00,0x5A5A5A,max4,mesure4)
  79.     pourcentage = math.floor(100*mesure4/max4)
  80.     gpu.set(19,45,..pourcentage.."%")
  81.    
  82. end
  83.  
  84. local function rack5()
  85.     gtank1 = component.get("34a5")
  86.     tank1 = component.proxy(gtank1)
  87.     mesure5 = tank1.getEnergyStored()
  88.     max5 = tank1.getMaxEnergyStored()
  89.     bargraph_horizontal(44,29,31,10,0x99FF00,0x5A5A5A,max5,mesure5)
  90.     pourcentage = math.floor(100*mesure5/max5)
  91.     gpu.set(58,45,..pourcentage.."%")
  92.    
  93. end
  94.  
  95. local function rack6()
  96.     gtank1 = component.get("738e")
  97.     tank1 = component.proxy(gtank1)
  98.     mesure6 = tank1.getEnergyStored()
  99.     max6 = tank1.getMaxEnergyStored()
  100.     bargraph_horizontal(83,29,31,10,0x99FF00,0x5A5A5A,max6,mesure6)
  101.     pourcentage = math.floor(100*mesure6/max6)
  102.     gpu.set(97,45,..pourcentage.."%")
  103.    
  104. end
  105.  
  106. local function total()
  107.     mesuretotale = mesure1 + mesure2 + mesure3 + mesure4 + mesure5 + mesure6
  108.     maxtotal = max1 + max2 + max3 + max4 + max5 + max6
  109.     bargraph_vertical(128,5,27,36,0xCC6D00,0x5A5A5A,maxtotal,mesuretotale)
  110.     pourcentage = math.floor(100*mesuretotale/maxtotal)
  111.     gpu.set(139,45,..pourcentage.."%")
  112.    
  113. end
  114.  
  115. term.clear
  116.  
  117. while true do
  118.    
  119.     affiche()
  120.     rack1()
  121.     rack2()
  122.     rack3()
  123.     rack4()
  124.     rack5()
  125.     rack6()
  126.     total()
  127.    
  128.     os.sleep(1)
  129. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement