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

Keyword Protected Door

Started by Jojomatik, 25 June 2014 - 03:03 PM
Jojomatik #1
Posted 25 June 2014 - 05: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.
GamerNebulae #2
Posted 25 June 2014 - 07:30 PM
What is your problem exactly?
Edited on 25 June 2014 - 05:50 PM
Jojomatik #3
Posted 25 June 2014 - 08: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.
GamerNebulae #4
Posted 25 June 2014 - 08:48 PM

print("Password: ")
term.setCursorPos(11,1)
pass=read() 
Done…
Jojomatik #5
Posted 25 June 2014 - 09:39 PM
Do I have to go on with my own code after this?
GamerNebulae #6
Posted 25 June 2014 - 10:15 PM
This is already an implementation to your code.
cptdeath58 #7
Posted 25 June 2014 - 10: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 on 25 June 2014 - 08:49 PM