Posted 17 June 2013 - 04:13 PM
I want to know if you are able to enter a username AND a password in the same program to unlock a computer. I've tried everything I know what to do. Help?
local valid
local accounts = {
["username"] = "password",
["foo"] = "bar",
["xolbor"] = "roblox",
["anavrin"] = "nirvana"
}
term.clear()
term.setCursorPos(1, 1)
print("Enter username")
write("> ")
local input_user = read()
print("Enter password")
write("> ")
local input_pass = read("*")
for valid_user, valid_pass in pairs(accounts) do
if (input_user == valid_user and input_pass == valid_pass) then valid = true end
end
if valid then print("Access Granted") else print("Access Denied") end
With the way you have set up that table you can do this-snip-
if accounts[input_user] == input_pass then
print("correct")
else
print("incorrect")
end