Advertisement
Guest User

rf.lua

a guest
Jun 22nd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.36 KB | None | 0 0
  1. local filesystem = require("filesystem")
  2. local colors = require("colors")
  3. local component = require("component")
  4. local term = require("term")
  5.  
  6. os.sleep(0.1)
  7. term.clear()
  8.  
  9.  
  10. gpu = component.gpu
  11. gpu.setResolution(80,18)
  12.  
  13. local fond_barre = 0xdcdcdc
  14. local barre = 0x21af0e
  15.  
  16. local function recuperation()
  17.   rf =  component.draconic_rf_storage.getEnergyStored()
  18.   max = component.draconic_rf_storage.getMaxEnergyStored()
  19.   pct = (rf * 100) / max
  20.   tick = component.draconic_rf_storage.getTransferPerTick()
  21. end
  22.  
  23.  
  24. local function bar_h(bar_x,bar_y,bar_l,pos,bar_h,color_barre,color_fond)
  25.   m = (bar_l/100)
  26.   f = math.floor(pos*m)
  27.  
  28.   gpu.setBackground(color_barre)
  29.   gpu.fill(bar_x,bar_y,f,bar_h," ")
  30.  
  31.   gpu.setBackground(color_fond)
  32.   gpu.fill((bar_x+f),bar_y,(bar_l-f),bar_h," ")  
  33. end
  34.  
  35. local function activation()
  36.   gpu.setBackground(0xFFFFFF)
  37.   gpu.fill(50,2,12,11," ")
  38.   gpu.setBackground(0x0000FF)
  39.   gpu.fill(64,2,12,11," ")
  40. end
  41.  
  42.  
  43. local function desactivation()
  44. end
  45.  
  46. local function affichage()
  47.   gpu.setForeground(0xFFFFFF)
  48.   gpu.setBackground(0x000000)
  49.   gpu.set(5,2,"Energie Maximum : "..max.." Rf")
  50.   gpu.set(5,4,"Energie Stockée : "..rf.." Rf")
  51.   gpu.set(5,6,"Transfert       : "..tick.." Rf/tick")
  52.   gpu.set(5,8,"Pourcentage     : "..pct.." %")
  53. end
  54.  
  55. term.clear()
  56.  
  57. while true do
  58.   recuperation()
  59.   affichage()
  60.   bar_h(5,14,70,pct,3,barre,fond_barre)
  61.   activation()
  62.   os.sleep(0.5)
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement