Advertisement
colhaydutu

atm9 xp screen

Jan 21st, 2024 (edited)
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. local monitor = peripheral.wrap("front")
  2. local tank = peripheral.wrap("right")
  3.  
  4. local function drawBar(x, y, width, fillPercentage)
  5. local fillWidth = math.floor(width * fillPercentage)
  6. paintutils.drawLine(1, 1, 10, 1, colors.lime)
  7. paintutils.drawLine(27, 1, 40, 1, colors.lime)
  8. term.redirect(monitor)
  9. monitor.setBackgroundColor(colors.white)
  10. monitor.setTextColor(colors.black)
  11.  
  12. monitor.setCursorPos(x, y)
  13. monitor.write("[ ")
  14.  
  15. for i = 1, width do
  16. if i <= fillWidth then
  17. monitor.setBackgroundColor(colors.green)
  18. monitor.write(" ")
  19. else
  20. monitor.setBackgroundColor(colors.red)
  21. monitor.write(" ")
  22. end
  23. end
  24.  
  25. monitor.setBackgroundColor(colors.white)
  26. monitor.write(" ] " .. math.floor(fillPercentage * 100) .. "%")
  27. end
  28.  
  29. while true do
  30. local info = tank.getInfo()
  31.  
  32. monitor.clear()
  33. monitor.setTextScale(0.9)
  34.  
  35. monitor.setCursorPos(5, 1)
  36.  
  37. monitor.write(" [INFO SCREEN] ")
  38. monitor.setCursorPos(1, 3)
  39. monitor.setBackgroundColor(colors.white)
  40. monitor.setTextColor(colors.lime)
  41. local infotk = info.amount / 1000
  42. local percentFull = (info.amount / info.capacity) * 100
  43.  
  44. monitor.write("Total: " .. infotk .. "Kb xp")
  45. monitor.setCursorPos(1, 5)
  46. monitor.write("Capacity: " .. (info.capacity / 1000) .. "Kb")
  47.  
  48.  
  49. drawBar(1, 7, 20, percentFull / 100)
  50.  
  51. os.sleep(1)
  52. end
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement