Jump to content




Keyword Protected Door

computer

  • You cannot reply to this topic
6 replies to this topic

#1 Jojomatik

  • Members
  • 11 posts

Posted 25 June 2014 - 04:03 PM

Hey guys,
I wanted to make a keyword-protected door. The first keyword should emit redstone at the backside... the second on the right. It works perfectly but there is one thing that I couldn't do:
My Code:
correctpass = ("password1")
correctpass2 = ("password2")
pass = read()
if correctpass == pass then
  redstone.setOutput("back",true)
  print("Keyword correct!")
  sleep(3)
  redstone.setOutput("back",false)
  os.shutdown()
  end
if correctpass2 == pass then
  redstone.setOutput("right",true)
  print("Put a senseless sentence here, which is not sentence one")
  sleep(3)
  redstone.setOutput("right",false)
  os.shutdown()
else
  print("Invalid Keyword")
  sleep(3)
  os.shutdown()
  end

As I sad before: works perfectly.

Now I want to something that says:
- Put in keyword here:
or:
- Keyword?

I tried it out yesterday and I don't know how I did it exactly.
So the program ran. It even emitted redstone but it said Keyword first when I had put the Keyword in. It looked like this:

password2
Keyword? Door opening...

Can you help me?
Thanks.

#2 GamerNebulae

  • Members
  • 216 posts
  • LocationNetherlands

Posted 25 June 2014 - 06:30 PM

What is your problem exactly?

Edited by GamerNebulae, 25 June 2014 - 06:50 PM.


#3 Jojomatik

  • Members
  • 11 posts

Posted 25 June 2014 - 07:04 PM

I want that the computer says something like "Write password here..." when I start him.
Momentary when you start the computer it says nothing and you have to write the keyword.

#4 GamerNebulae

  • Members
  • 216 posts
  • LocationNetherlands

Posted 25 June 2014 - 07:48 PM

print("Password: ")
term.setCursorPos(11,1)
pass=read() 
Done...

#5 Jojomatik

  • Members
  • 11 posts

Posted 25 June 2014 - 08:39 PM

Do I have to go on with my own code after this?

#6 GamerNebulae

  • Members
  • 216 posts
  • LocationNetherlands

Posted 25 June 2014 - 09:15 PM

This is already an implementation to your code.

#7 cptdeath58

  • Members
  • 139 posts
  • LocationError 404: Could not find.

Posted 25 June 2014 - 09:44 PM

You may need this:
correctpass = ("password1")
correctpass2 = ("password2")
pass = read()
elseif correctpass == pass then
  redstone.setOutput("back",true)
  print("Keyword correct!")
  sleep(3)
  redstone.setOutput("back",false)
  os.shutdown()
elseif correctpass2 == pass then
  redstone.setOutput("right",true)
  print("Put a senseless sentence here, which is not sentence one")
  sleep(3)
  redstone.setOutput("right",false)
  os.shutdown()
else
  print("Invalid Keyword")
  sleep(3)
  os.shutdown()
end
To help simply it a bit.

Edited by cptdeath58, 25 June 2014 - 09:49 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users