Advertisement
ETvd

ATM 10 Induction Matrix Monitor

Jun 21st, 2025
508
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.39 KB | None | 0 0
  1. -- Wrap the monitor (assuming only 1 is connected)
  2. local monitor = peripheral.find("monitor")
  3. if not monitor then
  4.     print("Monitor not found.")
  5.     return
  6. end
  7. monitor.setTextScale(0.5) -- Adjust to fit your monitor size
  8.  
  9. -- Wrap the Induction Matrix port
  10. local matrix = peripheral.find("inductionPort") -- or "inductionMatrix" depending on your world
  11. if not matrix then
  12.     print("Induction Matrix port not found.")
  13.     return
  14. end
  15.  
  16. -- Conversion ratio: Joules to Forge Energy
  17. local jouleToFeRatio = 276 / 690
  18.  
  19. -- Draw bar function (same as your original)
  20. local function drawBar(monitor, x, y, width, fillPercentage)
  21.     local w, h = monitor.getSize()
  22.     term.redirect(monitor)
  23.  
  24.     local borderOffset = math.floor(2 * 0.9)
  25.     local barWidth = math.floor(width * 0.9)
  26.  
  27.     paintutils.drawLine(2, 2, 2, 2, colors.lime)
  28.     paintutils.drawLine(math.floor(11 * 0.9), 2, w - borderOffset, 2, colors.lime)
  29.     paintutils.drawLine(2, 2, 2, h - borderOffset, colors.lime)
  30.     paintutils.drawLine(w - borderOffset, 2, w - borderOffset, h - borderOffset, colors.lime)
  31.     paintutils.drawLine(w - borderOffset, h - borderOffset, 2, h - borderOffset, colors.lime)
  32.  
  33.     monitor.setBackgroundColor(colors.gray)
  34.     monitor.setTextColor(colors.white)
  35.     monitor.setCursorPos(3, 2)
  36.     monitor.write("[INFO]")
  37.  
  38.     local fillWidth = math.floor(barWidth * fillPercentage)
  39.  
  40.     monitor.setBackgroundColor(colors.gray)
  41.     monitor.setTextColor(colors.white)
  42.     monitor.setCursorPos(x, y)
  43.     monitor.write("[ ")
  44.  
  45.     for i = 1, barWidth do
  46.         if i <= fillWidth then
  47.             monitor.setBackgroundColor(colors.green)
  48.             monitor.write(" ")
  49.         else
  50.             monitor.setBackgroundColor(colors.red)
  51.             monitor.write(" ")
  52.         end
  53.     end
  54.  
  55.     monitor.setBackgroundColor(colors.gray)
  56.     monitor.write(" ] " .. math.floor(fillPercentage * 100) .. "%")
  57. end
  58.  
  59. -- Main display loop
  60. while true do
  61.     local totalEnergyJoule = matrix.getEnergy()
  62.     local percentFull = matrix.getEnergyFilledPercentage() or 0
  63.     local totalEnergyFe = totalEnergyJoule * jouleToFeRatio
  64.  
  65.     monitor.clear()
  66.     drawBar(monitor, 5, 7, 18, percentFull)
  67.  
  68.     monitor.setCursorPos(5, 5)
  69.     monitor.setBackgroundColor(colors.gray)
  70.     monitor.setTextColor(colors.white)
  71.     monitor.write("Energy: " .. string.format("%.2f", totalEnergyFe / 1000) .. " kFe")
  72.  
  73.     os.sleep(1)
  74. end
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement