xXm0dzXx

RAT Host

Nov 17th, 2012
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. local x,y = term.getSize()
  2. local currentID = 0
  3.  
  4. local function cPrint(text)
  5. x2,y2 = term.getCursorPos()
  6. term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  7. write(text.. "\n")
  8. end
  9.  
  10. local function lWrite(text)
  11. x2,y2 = term.getCursorPos()
  12. term.setCursorPos(math.ceil( x - (text:len()-1) ), y2)
  13. write(text)
  14. end
  15.  
  16. term.clear()
  17. term.setCursorPos(1,3)
  18. cPrint("xXm0dzXx")
  19. cPrint("RAT Services")
  20. print()
  21. cPrint("+---Select a computer---+")
  22. local ids = {}
  23.  
  24. rednet.broadcast( "getText" )
  25. timer = os.startTimer(0)
  26. repeat
  27. local event, key, id = os.pullEvent()
  28. if event == "rednet_message" then
  29. ids[#ids+1] = key
  30. end
  31. until event == "timer" and key == timer
  32.  
  33. function addButton( curType, disID, text )
  34. local x2,y2 = term.getCursorPos()
  35. if disID == curType then
  36. yer = "X"
  37. else
  38. yer = " "
  39. end
  40. cPrint("| [" ..yer.. "]|")
  41. term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  42. write("| " ..text)
  43. end
  44.  
  45.  
  46. selection = 1
  47. clockeroo = os.startTimer(0.05)
  48. while true do
  49. term.clear()
  50. term.setCursorPos(1,3)
  51. cPrint("xXm0dzXx")
  52. cPrint("RAT Services")
  53. print()
  54. cPrint("+---Select a computer---+")
  55. if #ids == 0 then
  56. cPrint("| No Computers Found, |")
  57. cPrint("| Enter a id: |")
  58. cPrint("+-----------------------+")
  59. currentID = tonumber(read())
  60. break
  61. end
  62. for i=1,#ids do
  63. v = ids[i]
  64. addButton( selection, i, "#" ..v )
  65. end
  66. cPrint("+-----------------------+")
  67. term.setCursorPos(1,y)
  68. lWrite( textutils.formatTime( os.time() ) )
  69.  
  70. local event, key = os.pullEvent()
  71. if event == "key" then
  72. if key == keys.up and selection ~= 1 then
  73. selection = selection -1
  74. elseif key == keys.down and selection ~= #ids then
  75. selection = selection +1
  76. elseif key == keys.enter then
  77. currentID = ids[ selection ]
  78. break
  79. end
  80. elseif event == "timer" then
  81. clockeroo = os.startTimer(0.05)
  82. end
  83. end
  84.  
  85. term.clear()
  86. term.setCursorPos(1,3)
  87. cPrint("+---CONNECTING---+")
  88. cPrint("| Please wait :D |")
  89. cPrint("+----------------+")
  90. sleep(1)
  91.  
  92. function getFrom( msg, idz )
  93. repeat
  94. rednet.send( msg, idz )
  95. id, message = rednet.receive()
  96. until id == msg
  97. return message
  98. end
  99.  
  100. while true do
  101. local screenData = textutils.unserialize( getFrom( currentID, "getText" ) )
  102.  
  103. term.setBackgroundColour( screenData["clearColor"] )
  104. term.clear()
  105.  
  106. for i=1,#screenData-1 do
  107. term.setBackgroundColour( screenData[i]["bg"] )
  108. term.setTextColour( screenData[i]["cl"] )
  109. term.setCursorPos( screenData[i]["x"], screenData[i]["y"] )
  110. write( screenData[i]["text"] )
  111. end
  112.  
  113. term.setTextColour( colors.red )
  114. term.setCursorPos(1,y-1)
  115. lWrite("+-")
  116. term.setCursorPos(1,y)
  117. lWrite("| ")
  118. term.setTextColour( colors.green )
  119. lWrite("^")
  120.  
  121. term.setCursorBlink( textutils.unserialize( getFrom( currentID, "getBlink" ) ) )
  122. term.setTextColour( textutils.unserialize( getFrom( currentID, "getColor" ) ) )
  123. term.setBackgroundColour( textutils.unserialize( getFrom( currentID, "getBGColor" ) ) )
  124. term.setCursorPos( textutils.unserialize( getFrom( currentID, "getX" ) ), textutils.unserialize( getFrom( currentID, "getY" ) ) )
  125. end
Advertisement
Add Comment
Please, Sign In to add comment