Aadvert

Untitled

Feb 19th, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.45 KB | None | 0 0
  1. local password = "2good4u"
  2. local nPos = 1 -- Position we're at in the password
  3. repeat
  4.     local event, p1, p2 = os.pullEventRaw()
  5.  
  6.     if event == "char" then
  7.         if password:sub(nPos, nPos) == p1 then
  8.             nPos = nPos + 1
  9.         else
  10.             nPos = 1 -- Wrong character, reset password.
  11.         end
  12.     elseif event == "terminate" then
  13.         print("Too bad.")
  14.     end
  15. until nPos>#password -- Break when the attempt is longer than the password (e.g all characters are entered)
Advertisement
Add Comment
Please, Sign In to add comment