QuickMuffin8782-Alt

Untitled

Nov 8th, 2020 (edited)
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local function drawProgBar(done, max)
  2.  
  3. local value = done / max
  4. local _, y = term.getCursorPos()
  5. local wide, _ = term.getSize()
  6. term.setCursorPos(1,y)
  7. term.clearLine()
  8. term.write(("="):rep(math.floor(value * (wide - 6))))
  9. term.setCursorPos(math.floor(value * (wide - 6)), y)
  10. term.write(">")
  11. term.setCursorPos(wide - 6, y)
  12. term.write("]")
  13. term.setCursorPos(1, y)
  14. term.write("[")
  15. term.setCursorPos(wide - 5, y)
  16. term.write("     ")
  17.  
  18. local percent = math.floor(value * 100) .. "%"
  19. term.setCursorPos(wide - percent:len(),y)
  20. term.write(percent)
  21.  
  22. end
  23.  
  24. local x, y = term.getCursorPos()
  25. local maxNum = math.random(1, 500)
  26.  
  27. print(maxNum)
  28. for i = 1, maxNum do
  29.     term.setCursorPos(1,y+1)
  30.     drawProgBar(i, maxNum)
  31.     print()
  32.     sleep(0.01)
  33. end
  34. sleep(1)
  35.  
  36.  
Add Comment
Please, Sign In to add comment