Advertisement
xXm0dzXx

screenview server

Nov 11th, 2012
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. local x,y = term.getSize()
  2. local screenData = {}
  3. rednet.open("back")
  4.  
  5. write("Enter the ID: ")
  6. input = read()
  7.  
  8. function getFrom( iddd, message )
  9. repeat
  10. rednet.send( tonumber(iddd), tostring(message.. "") )
  11. event, id, message1 = os.pullEvent()
  12. until id == tonumber(iddd) and event == "rednet_message"
  13.  
  14. return message1
  15. end
  16.  
  17. function see()
  18. while true do
  19. term.clear()
  20. term.setCursorPos(1,1)
  21. screenData = textutils.unserialize( getFrom(input, "getScreen") )
  22. local shouldBlink = textutils.unserialize( getFrom(input, "getBlink") )
  23. if shouldBlink == true or shouldBlink == false then
  24. term.setCursorBlink( shouldBlink )
  25. end
  26.  
  27. for i=1,#screenData do
  28. local scr = screenData[i]
  29. term.setCursorPos(scr["x"], scr["y"])
  30. term.setBackgroundColour( scr["bgcolor"] )
  31. term.setTextColour( scr["color"] )
  32. term.write( scr["text"] )
  33. end
  34.  
  35. local positions = textutils.unserialize( getFrom(input, "getPos") )
  36. if type(positions) == "table" then
  37. for i,v in pairs( positions ) do
  38. print( v )
  39. end
  40. term.setCursorPos( positions["x"], positions["y"] )
  41. end
  42.  
  43. local colz = textutils.unserialize( getFrom(input, "getColz") )
  44. if type(colz) == "table" then
  45. term.setBackgroundColour( colz["bg"] )
  46. term.setTextColour( colz["tc"] )
  47. end
  48. sleep(0)
  49. end
  50. end
  51.  
  52. function addTo( lol, str )
  53. if lol then
  54. str = str.. ":" ..lol
  55. end
  56.  
  57. return str
  58. end
  59.  
  60. function sendz( _sFilter )
  61. local event, p1, p2, p3, p4, p5 = os.pullEventRaw( _sFilter )
  62. str = event
  63. if str == "char" or str == "key" or str == "terminate" or str == "mouse_click" or str == "mouse_drag" or str == "mouse_scroll" then
  64. str = addTo( p1, str )
  65. str = addTo( p2, str )
  66. str = addTo( p3, str )
  67. str = addTo( p4, str )
  68. str = addTo( p5, str )
  69. rednet.send( tonumber(input), tostring(str) )
  70. end
  71.  
  72. return event, p1, p2, p3, p4, p5
  73. end
  74.  
  75. sleep(0)
  76. os.pullEvent = sendz
  77. see()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement