Advertisement
Guest User

frontend

a guest
Aug 10th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.04 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1, 1)
  3. if not rednet.isOpen() then
  4.   term.setTextColor(colors.red)
  5.   print("No modem found...")
  6.   term.setTextColor(colors.blue)
  7.   print("Valid sides: ")
  8.   print("front/back/top/bottom/left/right")
  9.   print()
  10.   term.setTextColor(colors.purple)
  11.   print("Please enter a side:")
  12.   term.setCursorPos(22, 5)
  13.   term.setTextColor(colors.green)
  14.   rednet.open(read())
  15. end
  16.  
  17. term.clear()
  18. term.setCursorPos(1, 1)
  19. term.setTextColor(colors.purple)
  20. print("Username:")
  21. term.setTextColor(colors.green)
  22. term.setCursorPos(11, 1)
  23. local user = read()
  24.  
  25. term.setTextColor(colors.purple)
  26. print("Password:")
  27. term.setTextColor(colors.green)
  28. term.setCursorPos(11, 2)
  29. local pass = read("#")
  30.  
  31. ----------------------------------
  32.  
  33. local server = rednet.lookup("TP", "TPSERV")
  34. term.setTextColor(colors.orange)
  35. print("Contacting server...")
  36. rednet.send(server, "GET", "TP")
  37. id, message = rednet.receive("TP", 5)
  38. rednet.send(server, user, "TP")
  39. rednet.send(server, pass, "TP")
  40.  
  41. id, message = rednet.receive("TP", 5)
  42. if message == "AUTH OK" then
  43.   term.setTextColor(colors.green)
  44.   print("Authentication for "..user.." successful")
  45. else
  46.   term.setTextColor(colors.red)
  47.   print("Authentication failure for "..user)
  48.   return
  49. end
  50.  
  51. ----------------------------------
  52.  
  53. loc = {}
  54. term.setTextColor(colors.orange)
  55. print("Retreiving locations...")
  56. while(true) do
  57.   id, message = rednet.receive("TP", 5)
  58.   if message == "END" then
  59.     break
  60.   end
  61.  
  62.   loc[#loc+1] = message
  63. end
  64.  
  65. term.clear()
  66. term.setCursorPos(1, 1)
  67. term.setTextColor(colors.purple)
  68. print("#|Name")
  69. term.setTextColor(colors.lime)
  70. for i = 1 , #loc do
  71.   print(loc[i])
  72. end
  73. print()
  74.  
  75. ----------------------------------
  76. term.setTextColor(colors.purple)
  77. print("Enter destination ID(#):")
  78. term.setCursorPos(26, #loc+3)
  79. term.setTextColor(colors.green)
  80. local dest = read()
  81.  
  82. rednet.send(server, "GOTO", "TP")
  83. id, message = rednet.receive("TP", 5)
  84. rednet.send(server, user, "TP")
  85. rednet.send(server, pass, "TP")
  86. rednet.send(server, dest, "TP")
  87.  
  88. shell.run("/frontend")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement