This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
rex41043's profile picture

[help] need help with login program

Started by rex41043, 10 April 2012 - 09:52 PM
rex41043 #1
Posted 10 April 2012 - 11:52 PM
i need help to make a login program that will read the username and password form a file!
file eg.

user = user
password = password

like that and the login program will read it form a file can eny 1 help?
cant_delete_account #2
Posted 11 April 2012 - 12:15 AM
Here:

function correct()
--CODE THAT HAPPENS WHEN PASSWORD IS CORRECT
end
if not fs.exists("//.pass")
write("New Password: ")
input = read("*")
local pass = fs.open("//.pass","w")
pass.write(input)
pass.close()
end
local hFile = fs.open("//.pass","r")
local password = hFile.readAll()
hFile.close()
term.clear()
term.setCursorPos(1,1)
write("Password: ")
local ijkl = read("*")
if ijkl == (password) then
term.clear()
term.setCursorPos(1,1)
print("Password correct!")
correct()
sleep(1)
os.reboot()
else
term.clear()
term.setCursorPos(1,1)
print("Password incorrect!")
print("Shutting down...")
sleep(1)
os.reboot()
end