Posted 29 March 2013 - 05:48 PM
I've been working on a computer system with a login screen (back into ComputerCraft, yay!) When I run the program, everything works just fine, until I input the username; the error is:
Line 51 is:
And the whole code is:
Can anybody recognize the problem?
startup:51: attempt to index ? (a nil value)
Line 51 is:
local passOut = file.readAll()
And the whole code is:
Spoiler
rednet.open("right")
print(" YellowOS")
print("")
local first = true
local correct = false
if not fs.exists("bin/exists") then
local same = false
fs.makeDir("bin")
local f = fs.open("bin/exists", "w")
f.write("true")
f.close()
fs.makeDir("bin/users")
while not same do
term.clear()
term.setCursorPos(1, 1)
if not first then
print(" YellowOS")
print("")
end
print("Create new user: ")
local userIn = read()
print("New password: ")
local passIn = read("*")
print("Confirm password: ")
local confirmIn = read("*")
if passIn == confirmIn then
fs.makeDir("bin/users/"..userIn)
f = fs.open("bin/users/"..userIn.."/pass", "w")
f.write(passIn)
f.close()
same = true
end
first = false
end
else
while not correct do
print("Enter user: ")
local user = read()
if fs.exists("bin/users/"..user)then
local file = fs.open("bin/user/"..user.."/pass", "r")
local passOut = file.readAll()
print("Enter password: ")
local pass = read("*")
else
print("Incorrect username!")
end
if not pass == passOut then
print("")
print("Incorrect password!")
os.sleep(2000)
else
correct = true
end
end
end
Can anybody recognize the problem?