Guest User

Untitled

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