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

Locked Door with redstone override?

Started by Tassyr, 01 August 2015 - 03:18 PM
Tassyr #1
Posted 01 August 2015 - 05:18 PM
So I've got a very simple door lock set up.

while true do
  term.clear()
  term.setCursorPos(1,1)
  print("+-------------------------------------------------+")
  term.setCursorPos(1,2)
  print("|		    AIRLOCK SECURITY CONTROLS		    |")
  term.setCursorPos(1,3)
  print("+-------------------------------------------------+")
  term.setCursorPos(1,4)
  print("| Enter Password:								 |")
  term.setCursorPos(19, 4)
 
  input = read("*")
 
  if input == "password" then
    redstone.setOutput("left", true)
    redstone.setOutput("top", true)
    sleep(5)
    redstone.setOutput("left", false)
    redstone.setOutput("top", false)
  else
    term.setCursorPos(19,4)
    print("INVALID PASSWORD")
    sleep(5)
  end
end

What I'd like to do is put in an "Override" circuit. Basically if this thing is getting a signal from another terminal- redstone in through the back- it'll refuse any password and stay LOCKED. How would I go about doing that?
flaghacker #2
Posted 01 August 2015 - 05:47 PM
You could change the line where you check for a valid password to this:


if input == "password" and not rs.getInput("back") then

This now basically says: "if the password is valid and I'm not getting a redstone input from the back". Of course you can change "back" to any side.
Tassyr #3
Posted 01 August 2015 - 06:13 PM
It's that simple? I figured I had to do something to make it constantly check the redstone status?
flaghacker #4
Posted 01 August 2015 - 06:16 PM
No, rs.getInput checks the redstone signaal at the moment you call it. No complicatied stuff needed.