DorianH935

Untitled

Jun 25th, 2024
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. -- Mirroring program for ComputerCraft
  2. -- This program mirrors the computer's terminal display to a monitor named "monitor_5"
  3.  
  4. -- Find the attached monitor named "monitor_5"
  5. local monitor = peripheral.wrap("monitor_5")
  6.  
  7. if not monitor then
  8. print("No monitor named 'monitor_5' found!")
  9. return
  10. end
  11.  
  12. -- Set the monitor to be a text scale of 0.5 (optional, adjust as needed)
  13. monitor.setTextScale(0.5)
  14.  
  15. -- Function to mirror the terminal to the monitor
  16. local function mirrorDisplay()
  17. -- Get the size of the terminal
  18. local termWidth, termHeight = term.getSize()
  19.  
  20. -- Clear the monitor
  21. monitor.clear()
  22.  
  23. -- Loop through each line of the terminal and copy it to the monitor
  24. for y = 1, termHeight do
  25. local line = term.getLine(y) or ""
  26. monitor.setCursorPos(1, y)
  27. monitor.write(line)
  28. end
  29. end
  30.  
  31. -- Main loop to keep mirroring the display
  32. while true do
  33. -- Mirror the display
  34. mirrorDisplay()
  35.  
  36. -- Sleep for a short duration to prevent excessive CPU usage
  37. sleep(0.1)
  38. end
  39.  
Advertisement
Add Comment
Please, Sign In to add comment