Advertisement
Guest User

startup

a guest
Sep 26th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3. modem = peripheral.wrap("back")
  4.  
  5. print("Please Enter Password:")
  6. local input = read(" ")
  7.  
  8. if input == "test" then
  9. term.clear()
  10. term.setBackgroundColor(colors.gray)
  11. term.setCursorPos(1,1)
  12. print("Please Enter A PORT:")
  13. local str_port = read()
  14.  
  15. if str_port <= "65535" then
  16. term.clear()
  17. term.setCursorPos(1,1)
  18. port = tonumber(str_port)
  19. modem.open(port)
  20. print("Username:")
  21. local usr = read()
  22.  
  23. function Listener()
  24. while true do
  25. event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  26. if message ~= "" then
  27.     print(message)
  28.     print("")
  29. end
  30. end
  31. end
  32.  
  33. function SendMsg()
  34. while true do
  35. local event, param = os.pullEvent()
  36. if event == "key" and param == 28 then
  37. write(usr..": ")
  38. local msg = read()
  39. if msg ~= "" then
  40. modem.transmit(port,port,usr..": "..msg)
  41. end
  42. elseif event == "key" and param == 53 then
  43. print("############")
  44. write("COMMAND: ")
  45. local svid = tonumber(read())
  46. if svid ~= "" then
  47. local cmd = read()
  48. if cmd ~= "" then
  49. if svid == 0000 then
  50. print("############")
  51. if cmd == "CLR" then
  52. term.clear()
  53. term.setCursorPos(1,1)
  54. elseif cmd == "RBT" then
  55. os.reboot()
  56. end
  57. else
  58. modem.transmit(port,tonumber(svid),cmd)
  59. print("############")
  60. end
  61. end
  62. end
  63. end
  64. end
  65. end
  66.  
  67. if usr ~= "" then
  68. term.clear()
  69. term.setCursorPos(1,1)
  70. parallel.waitForAny(Listener,SendMsg)
  71.  
  72. end
  73. end
  74. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement