Advertisement
colhaydutu

steampunk stress screen

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