Advertisement
ElijahCrafter

Untitled

Mar 1st, 2024 (edited)
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | None | 0 0
  1. -- Sender Script
  2.  
  3. -- Define the side where the monitor is connected
  4. local monitorSide = "top" -- Change this to match your setup
  5.  
  6. -- Check if a monitor is connected
  7. if not peripheral.isPresent(monitorSide) or peripheral.getType(monitorSide) ~= "monitor" then
  8.     print("No monitor found on specified side.")
  9.     return
  10. end
  11.  
  12. -- Open the modem on the specified side
  13. local modem = peripheral.wrap("top")
  14. modem.open(123) -- Use any arbitrary port number you like
  15.  
  16. -- Function to capture and send the screen data
  17. local function sendScreenData()
  18.     while true do
  19.         local monitor = peripheral.wrap(monitorSide) -- Wrap the monitor peripheral
  20.         local width, height = monitor.getSize() -- Get screen size
  21.         local screenData = {} -- Initialize table to store screen data
  22.  
  23.         -- Capture screen data
  24.         for y = 1, height do
  25.             local line = {}
  26.             for x = 1, width do
  27.                 local char, textColor, bgColor = monitor.getPixel(x, y)
  28.                 table.insert(line, { char, textColor, bgColor })
  29.             end
  30.             table.insert(screenData, line)
  31.         end
  32.  
  33.         -- Send screen data
  34.         modem.transmit(123, 123, screenData)
  35.         os.sleep(0.1) -- Adjust this delay as needed
  36.     end
  37. end
  38.  
  39. -- Start sending screen data
  40. sendScreenData()
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement