Next time post
the full error message you get.
Your problem is using
break after
return. After returning (using
return keyword) or breaking out of the loop (using
break keyword) the code after
return or
break isn't executed, plus Lua expects an
end,
else,
until, etc. and doesn't even allow to write any code after those keywords.
It would be easier if you would setup your table using usernames as keys and passwords as values:
local users = {
["testuser"] = "testpassword",
["anotheruser"] = "123"
}
local username = read() --// Ask for a username
local password = read() --// Ask for a password
if users[username] and users[username] == password then --// If the user exists and the password is correct
print("Welcome " .. username .. "!")
else --// If the username or password was incorrect
print("Wrong username or password!")
end
Edited by MKlegoman357, 27 April 2014 - 07:22 PM.