Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Replace these with the actual monitor and modem addresses
- local monitorAddress = "right"
- local modemAddress = "left"
- local monitor = peripheral.wrap(monitorAddress)
- local computerID = os.getComputerID()
- function drawProgressBar(x, y, percentage)
- monitor.setCursorPos(x, y)
- monitor.setBackgroundColor(colors.white)
- monitor.clearRow(y)
- monitor.setBackgroundColor(colors.blue)
- local width = math.floor(percentage / 100 * (monitor.getSize()))
- monitor.setCursorPos(x, y)
- monitor.write(string.rep(" ", width))
- monitor.setBackgroundColor(colors.white)
- end
- function readRFAndDisplay()
- while true do
- local energyInfo = peripheral.call(modemAddress, "getEnergyInfo")
- if energyInfo then
- local rfPercentage = math.floor((energyInfo.energyStored / energyInfo.maxEnergyStored) * 100)
- monitor.clear()
- drawProgressBar(1, 1, rfPercentage)
- monitor.setCursorPos(1, 2)
- monitor.setTextColor(colors.black)
- monitor.write("RF: " .. rfPercentage .. "%")
- end
- sleep(5)
- end
- end
- -- Main program
- monitor.setBackgroundColor(colors.white)
- monitor.clear()
- monitor.setTextScale(1)
- readRFAndDisplay()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement