So I've been working on a login system for my computer, because i'm going to port my world to a server for me and my friends to play on, and the computer was also going to control a door next to the computer that led to a storage room.
So I figured that after asking for the login password, it would then ask if you wanted to enter the door to the left, and if you said no, it would open up to the rest of the computer, and if you said yes, it would initiate a door opening sequence and then return to the main computer. I before had decided that after getting into the program, you could just run a program that entered the door, but then it wouldn't be hidden by using the asterisk string, input = read("*") so I tried making a if statement after a if statement, it looked a little like this:
print("Welcome, please enter you're password:")
input = read("*")
if input == "HelloWorld" then
print("Password accepted, access granted.")
sleep(1)
print("Welcome rudemario, if you need to open the door to the left, please enter the correct password now:")
else
print("Password Incorrect, Access Denied."
sleep(1)
print("Initiating System Shutdown...")
sleep(1)
textutils.slowPrint("Goodbye!")
os.shutdown()
end
input = read("*")
if input == "creeperface" then
print("Password Accepted, Please Proceed.")
redstone.setOutput("left", true)
sleep(3)
redstone.setOutput("left", false)
print("Door now closed, enter the override code now to re-open the door.")
else
print("Welcome, rudemario.")
end
I have also tried to make the if statement inside of the if statement, and logically thats how it would go, right?
so now i'm at a stalemate, confused and frustrated, I request you're friendly community's help :/
4 replies to this topic
#1
Posted 28 October 2012 - 09:29 PM
#2
Posted 28 October 2012 - 09:38 PM
You mean something like this:
print("Welcome, please enter your password:")
input = read("*")
if input == "HelloWorld" then
print("Password accepted, access granted.")
sleep(1)
print("Welcome rudemario, if you need to open the door to the left, please enter the correct password now:")
input = read("*")
if input == "creeperface" then
print("Password Accepted, Please Proceed.")
redstone.setOutput("left", true)
sleep(3)
redstone.setOutput("left", false)
print("Door now closed, enter the override code now to re-open the door.")
else
print("Welcome, rudemario.")
end
else
print("Password Incorrect, Access Denied.")
sleep(1)
print("Initiating System Shutdown...")
sleep(1)
textutils.slowPrint("Goodbye!")
os.shutdown()
end
#3
Posted 28 October 2012 - 09:44 PM
Lyqyd, on 28 October 2012 - 09:38 PM, said:
You mean something like this:
print("Welcome, please enter your password:")
input = read("*")
if input == "HelloWorld" then
print("Password accepted, access granted.")
sleep(1)
print("Welcome rudemario, if you need to open the door to the left, please enter the correct password now:")
input = read("*")
if input == "creeperface" then
print("Password Accepted, Please Proceed.")
redstone.setOutput("left", true)
sleep(3)
redstone.setOutput("left", false)
print("Door now closed, enter the override code now to re-open the door.")
else
print("Welcome, rudemario.")
end
else
print("Password Incorrect, Access Denied.")
sleep(1)
print("Initiating System Shutdown...")
sleep(1)
textutils.slowPrint("Goodbye!")
os.shutdown()
end
Yes, I tried that, and can't seem to remember the error, but all I knew was that it actually looked just about identical to your post.
#4
Posted 28 October 2012 - 10:01 PM
So, did you try that exact code I just posted?
#5
Posted 28 October 2012 - 10:54 PM
You either have to give is the exact code or we can't look for errors.
The code you wrote already has a few syntax errors but I am guessing that it isn't the actual code.
The code you wrote already has a few syntax errors but I am guessing that it isn't the actual code.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











