Posted 07 April 2014 - 03:57 AM
Normally I would never resort to simply posting my code and saying "What's wrong?", but I have been forced to resort to this as I have no idea what is wrong.
function promptForUser(...)
local Args = {...}
print("Please Enter Username & Password")
term.write("Username: ")
local Username = read()
term.write("Password: ")
local uPass = read("*")
local User = {}
local cPass = {}
for i = 1, #Args/2, 2 do
User[i] = Args[i]
cPass[i] = Args[i+1]
end
for k,v in ipairs(User) do
if v == Username then
local x = k
end
end
if Username == User[x] and uPass == cPass[x] then
print("Welcome "..Username.."!")
return Username
else
print("Incorrect Username or Password!")
return promptForUser(...)
end
end
The only thing I can say is the error seems to be related to defining x. If I forcefully change x to 1, the values input for that username & password return correctly and are accepted if correct.