Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local password = "2good4u"
- local nPos = 1 -- Position we're at in the password
- repeat
- local event, p1, p2 = os.pullEventRaw()
- if event == "char" then
- if password:sub(nPos, nPos) == p1 then
- nPos = nPos + 1
- else
- nPos = 1 -- Wrong character, reset password.
- end
- elseif event == "terminate" then
- print("Too bad.")
- end
- 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