Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Config
- monitor_side = "left"
- monitor_width = 30
- modem_side = "top"
- modem_channel = 100
- -- Init modem
- modem = peripheral.wrap(modem_side)
- modem.open(modem_channel)
- -- Init monitor
- monitor = peripheral.wrap(monitor_side)
- monitor.setBackgroundColor(colors.black)
- monitor.setTextColor(colors.white)
- monitor.clear()
- monitor.setCursorPos(1, 1)
- monitor.write("Waiting for messages")
- print("Started. Hold Ctrl+T to terminate.")
- while true do
- -- Wait for events
- local ev, side, sch, rch, msg, dist = os.pullEvent("modem_message")
- local result = textutils.unserialize(msg)
- -- Draw progress bar
- line = result[1] * 2
- width = (result[3] / result[4]) * monitor_width
- prev = term.redirect(monitor)
- paintutils.drawFilledBox(0, line, monitor_width, line, colors.red)
- paintutils.drawFilledBox(0, line, width, line, colors.green)
- term.redirect(prev)
- -- Draw text
- value = math.floor(result[3] * 100.0) / 100.0
- monitor.setBackgroundColor(colors.black)
- monitor.setCursorPos(1, line - 1)
- monitor.clearLine()
- monitor.write(result[2]..": "..value..result[5])
- end
Advertisement
Add Comment
Please, Sign In to add comment