NeoGriever

Untitled

Jul 21st, 2024
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. -- Define dimension builders
  2. local dbs = {
  3. {material = "Redstone-Erz", peri = peripheral.wrap("dimension_builder_0")},
  4. {material = "Yellorit-Erz", peri = peripheral.wrap("dimension_builder_1")},
  5. {material = "Quarzblock", peri = peripheral.wrap("dimension_builder_2")},
  6. {material = "Goldblock", peri = peripheral.wrap("dimension_builder_3")},
  7. {material = "Drakonisches Erz", peri = peripheral.wrap("dimension_builder_4")},
  8. {material = "Diamant-Erz", peri = peripheral.wrap("dimension_builder_5")},
  9. {material = "Glowstone", peri = peripheral.wrap("dimension_builder_6")},
  10. {material = "Certusquarz", peri = peripheral.wrap("dimension_builder_7")},
  11. {material = "Eisen-Erz", peri = peripheral.wrap("dimension_builder_8")}
  12. }
  13.  
  14. local mon = peripheral.wrap("monitor_1")
  15. mon.setTextScale(0.5)
  16.  
  17. local m_w, m_h = mon.getSize()
  18. local left_offset = 1
  19. local block_size = 18
  20. local num_blocks = math.floor(m_w / block_size)
  21.  
  22. -- Function to draw a vertical bar
  23. local function drawBar(x, y, height, value, max_value, color)
  24. local fill_height = math.floor(height * value / max_value)
  25.  
  26. for i = 0, height - 1 do
  27. mon.setCursorPos(x, y + i)
  28. if i < fill_height then
  29. mon.setBackgroundColor(color)
  30. mon.write(" ")
  31. else
  32. mon.setBackgroundColor(colors.black)
  33. mon.write(" ")
  34. end
  35. end
  36. end
  37.  
  38. -- Main drawing function
  39. local function drawMonitor()
  40. mon.clear()
  41. mon.setBackgroundColor(colors.black)
  42. mon.setTextColor(colors.white)
  43.  
  44. for i, db in ipairs(dbs) do
  45. if i > num_blocks then break end
  46.  
  47. local x = left_offset + (i - 1) * block_size
  48.  
  49. -- Write material name
  50. mon.setCursorPos(x, 1)
  51. mon.write(db.material:sub(1, block_size - 1))
  52.  
  53. -- Get values
  54. local building_percentage = db.peri.getBuildingPercentage()
  55. local dimension_power = db.peri.getDimensionPower()
  56.  
  57. -- Draw BuildingPercentage bar
  58. drawBar(x, 3, m_h - 2, building_percentage, 100, colors.gray)
  59.  
  60. -- Draw DimensionPower bar
  61. drawBar(x + block_size / 2, 3, m_h - 2, dimension_power, 40000000, colors.green)
  62. end
  63. end
  64.  
  65. while true do
  66. drawMonitor()
  67. sleep(1) -- Update every second
  68. end
Advertisement
Add Comment
Please, Sign In to add comment