Marcelus

demo progressbar

Sep 10th, 2020
815
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. API = require("API_progressbar")
  2.  
  3. local component = require("component")
  4. local mon = component.gpu
  5. local w, h = mon.getResolution()
  6.  
  7. function clear()
  8.   mon.setBackground(BLACK)
  9.   mon.fill(1, 1, w, h, " ")
  10. end
  11.  
  12. API.setTable('bar1', 3, 63, 3, 5, 0, 100, 0, RIGHT, DARKGREY, CHROMA)
  13. API.setTable('bar2', 3, 63, 8, 10, 0, 100, 100, LEFT, DARKGREY, CHROMA)
  14.  
  15. API.setTable('bar3', 3, 5, 13, 45, 0, 100, 0, UP, DARKGREY, CHROMA)
  16. API.setTable('bar4', 8, 10, 13, 45, 0, 100, 100, DOWN, DARKGREY, CHROMA)
  17.  
  18. local i = 0
  19. local j = 1
  20.  
  21. clear()
  22.  
  23. while true do
  24.     API.set_value('bar1', i)
  25.     API.set_value('bar2', 100-i)
  26.     API.set_value('bar3', i)
  27.     API.set_value('bar4', 100-i)
  28.  
  29.     API.drawScreen()
  30.  
  31.     if i == 100 then
  32.         j = -1
  33.     elseif i == 0 then
  34.         j = 1
  35.     end
  36.  
  37.     i = i + j
  38.     os.sleep(.1)
  39.  
  40. end
RAW Paste Data