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

Need Help My Login Wont Work

Started by BrettSmith21, 27 June 2012 - 07:03 AM
BrettSmith21 #1
Posted 27 June 2012 - 09:03 AM
Can You Please Help Me My Login Doesn't Work
Can You Please Tell Me What Is Wrong??
Here Is The Code

admin = "admin"
Apass = "admin"
default = "default"
Dpass = "default"
shell.run("clear")
print("--Mine7 Login--")
print("Users:")
print("[Admin]")
print("[Default]")
status, input = pcall (read)
if input == admin then
print "Password:"
status, password = pcall (read,'*')
if password == Apass then
print "Access Granted!"
sleep(2)
shell.run("cd","Admin")
shell.run("clear")
else
print("Access Denied!")
sleep(2)
os.shutdown()
end
elseif input == default then
print "Password:"
status, password = pcall (read,'*')
if password == Dpass then
print "Access Granted!"
sleep(2)
shell.run("cd","Default")
shell.run("clear")
else
print "Access Denied!"
sleep(2)
os.shutdown()
end
Thanks
BigSHinyToys #2
Posted 27 June 2012 - 09:42 AM
you missed a end statement. ALSO please direct all questions to the ASK A PRO section.


Fixed Code
Spoiler

admin = "admin"
Apass = "admin"
default = "default"
Dpass = "default"
shell.run("clear")
print("--Mine7 Login--")
print("Users:")
print("[Admin]")
print("[Default]")
status, input = pcall (read)
if input == admin then
    print "Password:"
    status, password = pcall (read,'*')
    if password == Apass then
	    print "Access Granted!"
	    sleep(2)
	    shell.run("cd","Admin")
	    shell.run("clear")
    else
	    print("Access Denied!")
	    sleep(2)
	    os.shutdown()
    end
elseif input == default then
    print "Password:"
    status, password = pcall (read,'*')
    if password == Dpass then
	    print "Access Granted!"
	    sleep(2)
	    shell.run("cd","Default")
	    shell.run("clear")
    else
	    print "Access Denied!"
	    sleep(2)
	    os.shutdown()
    end -- needed a end here
elseif input ~= admin and input ~= default then -- to stop people bypassing your script.
    print "Access Denied!"
    sleep(2)
    os.shutdown()
end