Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Wrap the monitor (assuming only 1 is connected)
- local monitor = peripheral.find("monitor")
- if not monitor then
- print("Monitor not found.")
- return
- end
- monitor.setTextScale(0.5) -- Adjust to fit your monitor size
- -- Wrap the Induction Matrix port
- local matrix = peripheral.find("inductionPort") -- or "inductionMatrix" depending on your world
- if not matrix then
- print("Induction Matrix port not found.")
- return
- end
- -- Conversion ratio: Joules to Forge Energy
- local jouleToFeRatio = 276 / 690
- -- Draw bar function (same as your original)
- local function drawBar(monitor, x, y, width, fillPercentage)
- local w, h = monitor.getSize()
- term.redirect(monitor)
- local borderOffset = math.floor(2 * 0.9)
- local barWidth = math.floor(width * 0.9)
- paintutils.drawLine(2, 2, 2, 2, colors.lime)
- paintutils.drawLine(math.floor(11 * 0.9), 2, w - borderOffset, 2, colors.lime)
- paintutils.drawLine(2, 2, 2, h - borderOffset, colors.lime)
- paintutils.drawLine(w - borderOffset, 2, w - borderOffset, h - borderOffset, colors.lime)
- paintutils.drawLine(w - borderOffset, h - borderOffset, 2, h - borderOffset, colors.lime)
- monitor.setBackgroundColor(colors.gray)
- monitor.setTextColor(colors.white)
- monitor.setCursorPos(3, 2)
- monitor.write("[INFO]")
- local fillWidth = math.floor(barWidth * fillPercentage)
- monitor.setBackgroundColor(colors.gray)
- monitor.setTextColor(colors.white)
- monitor.setCursorPos(x, y)
- monitor.write("[ ")
- for i = 1, barWidth do
- if i <= fillWidth then
- monitor.setBackgroundColor(colors.green)
- monitor.write(" ")
- else
- monitor.setBackgroundColor(colors.red)
- monitor.write(" ")
- end
- end
- monitor.setBackgroundColor(colors.gray)
- monitor.write(" ] " .. math.floor(fillPercentage * 100) .. "%")
- end
- -- Main display loop
- while true do
- local totalEnergyJoule = matrix.getEnergy()
- local percentFull = matrix.getEnergyFilledPercentage() or 0
- local totalEnergyFe = totalEnergyJoule * jouleToFeRatio
- monitor.clear()
- drawBar(monitor, 5, 7, 18, percentFull)
- monitor.setCursorPos(5, 5)
- monitor.setBackgroundColor(colors.gray)
- monitor.setTextColor(colors.white)
- monitor.write("Energy: " .. string.format("%.2f", totalEnergyFe / 1000) .. " kFe")
- os.sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement