Guest User

Untitled

a guest
Jan 21st, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.30 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. Desktop()
  89. elseif msg == "no" then
  90. Desktop()
  91. end
  92.  
  93.  
  94. end
  95. end
  96. end
  97. end
  98.  
  99. local function Desktop()
  100. while true do
  101. local time = os.time()
  102. time = textutils.formatTime(time, false)
  103. term.clear()
  104. shell.run("clear")
  105. print("Logged In As: ", Username, "                ComputerID: ", Compid)
  106. term.setCursorPos(1,5)
  107. print("                            _____ __  ")
  108. print("     /\                    | ____/_ | ")
  109. print("    /  \   _ __ ___  __ _  | |__  | | ")
  110. print("   / /\ \ | '__/ _ \/ _` | |___ \ | | ")
  111. print("  / ____ \| | |  __/ (_| |  ___) || | ")
  112. print(" /_/    \_\_|  \___|\__,_| |____/ |_| ")
  113. term.setCursorPos(1,17)
  114. term.write("|=====|------------------------------------------|")
  115. print("|SHIFT|                                 |", time ,"|")
  116. term.setCursorPos(1,19)
  117. term.write("|=====|------------------------------------------|")
  118. event, id = os.pullEvent()
  119. if event == "key" and id == "25" then
  120. Menu()
  121. end
  122. if event == "key" and id == "42" then
  123. event, id = os.pullEvent()
  124. if event == "char" and id == "l" then
  125. Logout()
  126. else end
  127. end
  128. end
  129. end
  130.  
  131. local function Logout()
  132. shell.run("clear")
  133. print("Logout")
  134. sleep(2)
  135. end
  136.  
  137. local function Menu()
  138. shell.run("clear")
  139. print("menu function")
  140. sleep(2)
  141. end
  142.  
  143.  
  144.  
  145. --program
  146. while true do
  147. Login()
  148. end
Add Comment
Please, Sign In to add comment