Advertisement
colhaydutu

steampunk xp screen

Apr 11th, 2024 (edited)
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. local capacity = 504 * 1000
  2.  
  3. local monitor = peripheral.wrap("front")
  4. local tank = peripheral.wrap("right")
  5.  
  6. local function drawBar(x, y, width, fillPercentage)
  7. local fillWidth = math.floor(width * fillPercentage)
  8. paintutils.drawLine(1, 1, 10, 1, colors.lime)
  9. paintutils.drawLine(27, 1, 40, 1, colors.lime)
  10. term.redirect(monitor)
  11. monitor.setBackgroundColor(colors.white)
  12. monitor.setTextColor(colors.black)
  13.  
  14. monitor.setCursorPos(x, y)
  15. monitor.write("[ ")
  16.  
  17. for i = 1, width do
  18. if i <= fillWidth then
  19. monitor.setBackgroundColor(colors.green)
  20. monitor.write(" ")
  21. else
  22. monitor.setBackgroundColor(colors.red)
  23. monitor.write(" ")
  24. end
  25. end
  26.  
  27. monitor.setBackgroundColor(colors.white)
  28. monitor.write(" ] " .. string.format("%.2f", fillPercentage * 100) .. "%") -- Yüzdeliği ondalık olarak göstermek için %.2f formatını kullanıyoruz
  29. end
  30.  
  31. while true do
  32. local tanks = tank.tanks()
  33. local info = tanks[1]
  34.  
  35. monitor.clear()
  36. monitor.setTextScale(0.9)
  37.  
  38. monitor.setCursorPos(5, 1)
  39.  
  40. monitor.write(" [INFO SCREEN] ")
  41. monitor.setCursorPos(1, 3)
  42. monitor.setBackgroundColor(colors.white)
  43. monitor.setTextColor(colors.lime)
  44.  
  45. local infotk = info and (info.amount / 1000 * 1000) or 0
  46.  
  47. local capacityMB = capacity
  48. local percentFull = (info and info.amount or 0) / capacity * 100
  49.  
  50. monitor.write("Total: " .. infotk .. " MB xp")
  51. monitor.setCursorPos(1, 5)
  52. monitor.write("Capacity: " .. capacityMB .. " MB")
  53.  
  54. drawBar(1, 7, 20, percentFull / 100)
  55.  
  56. os.sleep(1)
  57. end
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement