Help!
elliotjarnit 19 Nov 2016
So im trying to make a
1: Password file maker(Works)
2: Password protected computer that when you type in a password in a file(password) then it breaks and ends(Not Working)
Here's the code for the first one:
1: Password file maker(Works)
2: Password protected computer that when you type in a password in a file(password) then it breaks and ends(Not Working)
Here's the code for the first one:
write("New Password: ") input = read() if input == "F" then shell.run("startup") end local file = fs.open("password", "w") file.writeLine(input) file.close()Now the one thats not working(Called startup):
write("Enter Password: ") user = read() local file = fs.open("password", "r") file.readLine() file.close() if user == file then print("Correct!") sleep(2) shell.run("system") else print("Incorrect") sleep(2) os.reboot() end
supernicejohn 19 Nov 2016
You would want to save the result of 'file.readLine' into a variable, then compare that instead of comparing a string with a file handle.
The wiki has good support on the fs API
Good luck!
The wiki has good support on the fs API
Good luck!
Mao Zedong 19 Nov 2016
write("Enter Password: ") user = read() local file = fs.open("password", "r") local pass = file.readLine() file.close() if user == pass then print("Correct!") sleep(2) shell.run("system") else print("Incorrect") sleep(2) os.reboot() end