Doyle3694, on 10 October 2012 - 05:09 PM, said:
I think this was from my password program, and it basically loops for as many variables there are in the table users
then it checks if the username entered is equal to variable number 1 in the table users. if that is, it will change the variable userNum to the current loop number. And then it will break the loop. if it's not equal, then it will loop again, and next loop it will take the second variable in users, because we are in the second loop. and if it's correct here it will set the current loop number to userNum and break. to make it not case sensitive, do
userEntered = string.lower(userEntered)
in the beginning. This is useful for multi acc password programs.
Ahh yes, I recognize your name

/> Nice code btw (if it is yours

/>). And thanks for explaining. I've been fooling around with it for quite a while now... And thanks for showing me how to make strings lowercase

/>
If this is your code, could you explain one more thing to me?
function readUsersAndPasswords()
fs.makeDir("passwordFolder")
regUser = fs.open("passwordFolder/users","a")
regPassword = fs.open("passwordFolder/passwords","a")
regUser.close()
regPassword.close()
users = {}
passwords = {}
userFile = fs.open("passwordFolder/users","r")
passwordFile = fs.open("passwordFolder/passwords","r")
lineRead = userFile.readLine()
repeat
table.insert(users,lineRead)
lineRead = userFile.readLine()
until lineRead == nil
lineRead = passwordFile.readLine()
repeat
table.insert(passwords,lineRead)
lineRead = passwordFile.readLine()
until lineRead == nil
passwordFile.close()
userFile.close()
end
The part where it repeats, does it enter the line read each time into the users / passwords table? And when it reads nil it ends?