Smiley43210

Login Client

Apr 10th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.43 KB | None | 0 0
  1. -- To prevent people from using Ctrl + T on this program, uncomment the next two commented lines AND the very last line. Don't do it until both programs actually work together.
  2. --local oldPullEvent = os.pullEvent
  3. --os.pullEvent = os.pullEventRaw
  4.  
  5. while true do -- Repeat the login loop until a user logs in successfully
  6.     print("  Login  ")
  7.     print("=========")
  8.     sleep(1)
  9.     print(" ")
  10.     sleep(1)
  11.     print("Username: ")
  12.     sleep(1)
  13.     login = read() --you enter your username
  14.     sleep(1)
  15.     rednet.open("right") --open connection to the modem
  16.     rednet.send(3, login) --send the username to pc3(DB PC)
  17.     sleep(2)
  18.     x,y,z = rednet.receive() --waiting for the answer with the pw or wpw message
  19.     if y == "wpw" then --if wpw then restart the login process
  20.         print("Wrong username!")
  21.         sleep(1)
  22.     else
  23.         sleep(1)
  24.         print("Password: ")
  25.         sleep(1)
  26.         -- It can be simplified to just this, since you don't ever reference to the pw variable again
  27.         if read("*") == y then --if the entered password is equal to the pw sent back by the DB then access is granted
  28.         print("Access Granted!")
  29.         sleep(1)
  30.         print("Main menu following...")
  31.         sleep(2)
  32.         break -- Exit the while loop and the program
  33.     else --if it's not equal start the program again
  34.         print("Wrong password!")
  35.         sleep(1)
  36.     end
  37. end
  38.  
  39. --os.pullEvent = oldPullEvent
Advertisement
Add Comment
Please, Sign In to add comment