Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Mirroring program for ComputerCraft
- -- This program mirrors the computer's terminal display to a monitor named "monitor_5"
- -- Find the attached monitor named "monitor_5"
- local monitor = peripheral.wrap("monitor_5")
- if not monitor then
- print("No monitor named 'monitor_5' found!")
- return
- end
- -- Set the monitor to be a text scale of 0.5 (optional, adjust as needed)
- monitor.setTextScale(0.5)
- -- Function to mirror the terminal to the monitor
- local function mirrorDisplay()
- -- Get the size of the terminal
- local termWidth, termHeight = term.getSize()
- -- Clear the monitor
- monitor.clear()
- -- Loop through each line of the terminal and copy it to the monitor
- for y = 1, termHeight do
- local line = term.getLine(y) or ""
- monitor.setCursorPos(1, y)
- monitor.write(line)
- end
- end
- -- Main loop to keep mirroring the display
- while true do
- -- Mirror the display
- mirrorDisplay()
- -- Sleep for a short duration to prevent excessive CPU usage
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment