Guest User

Untitled

a guest
Jan 21st, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.37 KB | None | 0 0
  1. --settings
  2. Username = "User1"
  3. Compid = os.computerID()
  4. Label = os.getComputerLabel()
  5. LoginServ = 1337
  6. rednet.open("right")
  7. rednet.open("left")
  8. rednet.open("front")
  9. rednet.open("back")
  10. rednet.open("top")
  11. rednet.open("bottom")
  12. ready = 0
  13.  
  14.  
  15. --functions
  16. local function Login()
  17. shell.run("clear")
  18. term.setCursorPos(15,9)
  19. write ("Username: ")
  20. UserIn = read()
  21. term.clear()
  22. term.setCursorPos(15,9)
  23. write ("Password: ")
  24. PassIn = read()
  25.  
  26. ping = rednet.send(LoginServ, "Ping")
  27. if ping == True then
  28. elseif ping == False then
  29. term.setCursorPos(15,9)
  30. write ("Error 32: Login Servers Can Not Be Reached")
  31. term.setCursorPos(15,10)
  32. write ("Please Report this error to your local Administrator")
  33. sleep(2)
  34. i = 0
  35.  
  36. while ready == 0 do
  37. i = i + 1
  38. if i = 5 then
  39. print("Login Servers Busy, Try Again")
  40. sleep(3)
  41. os.reboot()
  42. rednet.send(LoginServ, "Waiting")
  43. id, msg = rednet.recieve(0.1)
  44. if msg == "ready" then
  45. ready = 1
  46. end
  47. end
  48.  
  49. rednet.send(LoginServ, UserIn)  -- Sends username to Login Server
  50. rednet.send(LoginServ, PassIn)  -- Sends Password to login server to compare
  51. id, msg = rednet.receive(2)
  52.  
  53. if msg == "Invalid" then
  54. term.clear()
  55. term.setCursorPos(15,9)
  56. write ("Access Denied")
  57. term.setCursorPos(15,10)
  58. write ("Username and Password do not match")
  59. sleep(3)
  60. os.shutdown()
  61.  
  62. elseif msg == "Correct" then
  63. rednet.send(LoginServ, Label) -- Sends the Comp label to login server to check if user has clearance
  64. id, msg = rednet.receive(2)
  65.  
  66. elseif msg == "Denied" then
  67. term.clear()
  68. term.setCursorPos(15,9)
  69. write ("You do not have access to this terminal")
  70. sleep(3)
  71. os.shutdown()
  72. elseif msg == "Granted" then
  73. rednet.send(LoginServ, "IsFirst")
  74. id, msg = rednet.receive(2)
  75. if msg == "yes" then
  76. term.setCursorPos(15,9)
  77. write ("This is your first time logining in.")
  78. term.setCursorPos(15,10)
  79. write ("Please Enter Your New Password")
  80. term.setCursorPos(15,11)
  81. write ("Password: ")
  82. NewPass = read()
  83. rednet.send(LoginServ, NewPass)
  84. shell.run("clear")
  85. term.setCursorPos(15,9)
  86. write ("Your Password has been changed to: ", NewPass)
  87. sleep(1)
  88. rednet.send(LoginServ, "EndLogin")
  89. Desktop()
  90. elseif msg == "no" then
  91. rednet.send(LoginServ, "EndLogin")
  92. Desktop()
  93. end
  94.  
  95.  
  96. end
  97. end
  98. end
  99. end
  100.  
  101. local function Desktop()
  102. while true do
  103. local time = os.time()
  104. time = textutils.formatTime(time, false)
  105. term.clear()
  106. shell.run("clear")
  107. print("Logged In As: ", Username, "                ComputerID: ", Compid)
  108. term.setCursorPos(1,5)
  109. print("                            _____ __  ")
  110. print("     /\                    | ____/_ | ")
  111. print("    /  \   _ __ ___  __ _  | |__  | | ")
  112. print("   / /\ \ | '__/ _ \/ _` | |___ \ | | ")
  113. print("  / ____ \| | |  __/ (_| |  ___) || | ")
  114. print(" /_/    \_\_|  \___|\__,_| |____/ |_| ")
  115. term.setCursorPos(1,17)
  116. term.write("|=====|------------------------------------------|")
  117. print("|SHIFT|                                 |", time ,"|")
  118. term.setCursorPos(1,19)
  119. term.write("|=====|------------------------------------------|")
  120. event, id = os.pullEvent()
  121. if event == "key" and id == "25" then
  122. Menu()
  123. end
  124. if event == "key" and id == "42" then
  125. event, id = os.pullEvent()
  126. if event == "char" and id == "l" then
  127. Logout()
  128. else end
  129. end
  130. end
  131. end
  132.  
  133. local function Logout()
  134. shell.run("clear")
  135. print("Logout")
  136. sleep(2)
  137. end
  138.  
  139. local function Menu()
  140. shell.run("clear")
  141. print("menu function")
  142. sleep(2)
  143. end
  144.  
  145.  
  146.  
  147. --program
  148. while true do
  149. Login()
  150. end
Add Comment
Please, Sign In to add comment