xXm0dzXx

screenview test

Nov 11th, 2012
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. local serverID = 435
  2. isBlinkin = false
  3. currentBGColor = colors.black
  4. currentTColor = colors.white
  5. screenData = {}
  6.  
  7. oldWrr = term.write
  8.  
  9. term.write = function( strr )
  10. local x,y = term.getCursorPos()
  11. screenData[ #screenData+1 ] = {
  12. ["x"] = x,
  13. ["y"] = y,
  14. ["text"] = strr,
  15. ["color"] = currentTColor,
  16. ["bgcolor"] = currentBGColor,
  17. }
  18. return oldWrr( strr )
  19. end
  20.  
  21. oldClrr = term.clear
  22.  
  23. term.clear = function()
  24. screenData = {}
  25. return oldClrr()
  26. end
  27.  
  28. oldBG = term.setBackgroundColour
  29. oldTC = term.setTextColour
  30. oldBlinkah = term.setCursorBlink
  31. oldCursorPos = term.setCursorPos
  32.  
  33. term.setBackgroundColour = function( colah )
  34. currentBGColor = colah
  35. return oldBG( colah )
  36. end
  37.  
  38. term.setTextColour = function( colah )
  39. currentTColor = colah
  40. return oldTC( colah )
  41. end
  42.  
  43. term.setCursorBlink = function( yezornu )
  44. isBlinkin = yezornu
  45. return oldBlinkah( yezornu )
  46. end
  47.  
  48. function a()
  49. term.clear()
  50. term.setCursorPos(1,1)
  51.  
  52. shell.run("shell")
  53. end
  54.  
  55. function b()
  56. rednet.open("top")
  57. rednet.open("back")
  58. rednet.open("left")
  59. rednet.open("right")
  60. rednet.open("front")
  61. rednet.open("bottom")
  62. while true do
  63. local id, message = rednet.receive()
  64. if id == serverID and message == "getScreen" then
  65. rednet.send( id, textutils.serialize( screenData ) )
  66. elseif id == serverID and message == "getBlink" then
  67. rednet.send( id, textutils.serialize( isBlinkin ) )
  68. elseif id == serverID and message == "getPos" then
  69. local x,y = term.getCursorPos()
  70. local pos = {
  71. ["x"] = x,
  72. ["y"] = y,
  73. }
  74.  
  75. rednet.send( id, textutils.serialize( pos ) )
  76. elseif id == serverID and message == "getColz" then
  77. local colz = {
  78. ["bg"] = currentBGColor,
  79. ["tc"] = currentTColor,
  80. }
  81.  
  82. rednet.send( id, textutils.serialize( colz ) )
  83. elseif id == serverID and string.find( message, ":" ) then
  84. local tWords = {}
  85. for match in string.gmatch( message, "[^:\t]+" ) do
  86. table.insert( tWords, match )
  87. end
  88. os.queueEvent( tWords[1], tWords[2], tWords[3], tWords[4], tWords[5], tWords[6] )
  89. end
  90. end
  91. end
  92.  
  93. parallel.waitForAny( a, b )
Advertisement
Add Comment
Please, Sign In to add comment