Advertisement
jille_Jr

CC: Login Script Mk.2

Oct 5th, 2012
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.05 KB | None | 0 0
  1. function checkLogin(uname, pass)
  2.   -- Yes, very easy to hack...
  3.   if uname ~= "admin" and pass ~= "password" then
  4.     return true
  5.   else
  6.     return false
  7.   end
  8. end
  9.  
  10. function login()
  11.   local inputUname = ""
  12.   local inputPass = ""
  13.   local tries = 0
  14.  
  15.   while not checkLogin(inputUname, inputPass) do
  16.     term.clear()
  17.     if inputUname ~= "" or inputPass ~= "" then
  18.       term.setCursorPos(3,2)
  19.       print("Wrong username or password!")
  20.     end
  21.  
  22.     if tries > 4 then
  23.       term.setCursorPos(3,3)
  24.       print("No more tries left!")
  25.       sleep(2)
  26.       return false
  27.     end
  28.  
  29.     term.setCursorPos(3,3)
  30.     print("Username: ") -- 10 char long
  31.     term.setCursorPos(3,4)
  32.     print("Password: ") -- 10 char long
  33.     term.setCursorPos(3,5)
  34.     print("Tries left: "..5-tries)
  35.  
  36.     -- Now comes the input
  37.     term.setCursorPos(13,3)
  38.     inputUname = read()
  39.     term.setCursorPos(13,4)
  40.     inputPass = read("*")
  41.     tries = tries + 1
  42.   end
  43.   term.clear()
  44.   term.setCursorPos(3,2)
  45.   print("Correct login!")
  46.   sleep(2)
  47.   return true
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement