Advertisement
Guest User

energy.lua

a guest
Jul 21st, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. local component = require("component")
  2. local pc = component.computer
  3. local gpu = component.gpu
  4. local energy = component.basic_energy_cube
  5.  
  6. local counter = 0
  7. local w, h = gpu.getResolution()
  8. local max_energy = energy.getMaxEnergyStored()
  9.  
  10. function progressBar(ab, cd)
  11.   local presizedw = ((w - 15) / cd * ab)
  12.   gpu.setBackground(0x000000, false)
  13.   gpu.fill(3, 10, w - 15, 2, " ")
  14.  
  15.   gpu.setBackground(0x09EF70, false)
  16.   gpu.fill(3, 10, presizedw, 2, " ")
  17.   gpu.setBackground(0x123123, false)
  18. end
  19.  
  20. function startRendering()
  21.   local active_energy = energy.getEnergyStored()
  22.  
  23.   gpu.fill(1, 1, w, h, " ")
  24.   gpu.setForeground(0x000000, false)
  25.   gpu.setBackground(0xD9D9D9, false)
  26.  
  27.   progressBar(active_energy, max_energy)
  28.  
  29.   gpu.set(w / 2, h / 2, "energy: " .. active_energy)
  30.   gpu.setForeground(0x0980EF)
  31.  
  32. end
  33.  
  34. function caller()
  35.   while true do
  36.     os.sleep(0.5)
  37.     startRendering()
  38.   end
  39. end
  40.  
  41. caller()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement