Advertisement
Guest User

boule2

a guest
May 27th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.02 KB | None | 0 0
  1. local component = require("component")
  2. local term = require("term")
  3. local gpu = component.gpu
  4.    
  5.    
  6.     local boule   = component.draconic_rf_storage
  7.     local reactor = component.br_reactor
  8.  
  9.  
  10. local function info()
  11.    
  12.      info0 = boule.getTransferPerTick()
  13.      info1 = boule.getMaxEnergyStored()
  14.      info2 = boule.getEnergyStored()
  15.      info3 = reactor.getEnergyProducedLastTick()
  16.      info4 = info2/info1*100
  17.    
  18. end
  19.  
  20. local function miseEnPage()
  21.  
  22.      kTra  = (info0/1000)
  23.      Tmen  = (info1/1000000000000000000)
  24.      Ten   = (info2/1000000000000000000)
  25.      kprod = (info3/1000)
  26.    
  27. end
  28.  
  29. local function affiche()
  30.  
  31.     gpu.setBackground(0xffffff)
  32.     gpu.setForeground(0x023f63)
  33.  
  34.       gpu.set(2,4,string.format("Production reactor    : %2.2f kRF/t",kprod))
  35.       gpu.set(2,8,string.format("Max energie stocké    : %1.2f ERF",Tmen))
  36.      gpu.set(2,12,string.format("Energie stocké        : %1.2f ERF",Ten))
  37.      gpu.set(2,16,string.format("Energy en pct         : %3.2f",info4).." %")
  38.      gpu.set(2,21,string.format("Transfer energy boule : %2.2f kRF/t",kTra))
  39.    
  40.    
  41.   local fond_barre = 0xdcdcdc
  42.   local barre = 0x21af0e
  43.    
  44.      if info4 <= 50 then barre = 0xc81515 else barre = 0x21af0e end
  45.    
  46.      bar_h(5,18,38,info4,2,barre,fond_barre)
  47.    
  48.    gpu.setBackground(0x000000)
  49.    gpu.setForeground(0xffffff)
  50.  
  51. end
  52.  
  53. function bar_h(bar_x,bar_y,bar_l,pos,ep,color,fond)     -- barre horizontal syntax: bar_h(<pos colone>,<pos ligne>,<longueur>,<info>,<epaisseur de barre>,<couleur>,<fond>)
  54.      
  55.         local m = (bar_l/100)
  56.         local f = math.floor(pos*m)
  57.    
  58.         gpu.setBackground(color)
  59.         gpu.fill(bar_x,bar_y,f,ep," ")
  60.        
  61.         gpu.setBackground(fond)
  62.         gpu.fill((bar_x+f),bar_y,(bar_l-f),ep," ")
  63.    
  64. end
  65.  
  66.   term.clear()
  67.  
  68.  
  69. while true do
  70.      
  71.      info()  
  72.      miseEnPage()
  73.      affiche()
  74.      
  75.            if
  76.            info4 < 25
  77.            then
  78.             reactor.setActive(true)
  79.            elseif
  80.            info4 > 75
  81.            then
  82.            reactor.setActive(false)
  83.          
  84.           end
  85.  
  86.  
  87.  os.sleep(5)
  88.  
  89.  
  90. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement