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

Redstone pulse not working right.

Started by LlywMiner, 12 July 2012 - 02:28 PM
LlywMiner #1
Posted 12 July 2012 - 04:28 PM
i am using a Code lock i found online for my reactor chamber and i added in that when you do the password wrong there is a redstone output on for 1 sec in the back that goes to a toggle latch that activated a alarm, but whenever i put one of the codes the redstone goes of anyways, could you help me?
This is the incorrect password code

else
term.clear()
term.setCursorPos(1,1)
print("Password incorrect!")
redstone.setOutput("back", true)
sleep(1)
redstone.setOutput("back", false)
os.reboot()
end
This is the player 3 (me) password

if input == password3 then
term.clear()
term.setCursorPos(1,1)
print("Password correct!")
print("Welcome LlywMiner")--name of user 3
rs.setOutput(right,true)
sleep(4)
rs.setOutput(right,false)
os.reboot()
end
Lyqyd #2
Posted 12 July 2012 - 06:25 PM
Please post the whole program. It's impossible to diagnose control flow issues otherwise. Also you need quotes around "right" in the second example, unless that's a variable you've defined elsewhere.
mister_s #3
Posted 12 July 2012 - 06:52 PM
Here's what I would write:

term.clear()
term.setCursorPos(1,1)
password = "fghj"
write("Password please: ")
input = read()
if input==password then
  print("Password correct!")
  rs.setOutput("left",true)
  sleep(4)
  rs.setOutput("left",false)
  print(Rebooting computer...")
  os.reboot()
else
  print("Password incorrect!")
  rs.setOutput("right",true)
  sleep(1)
  rs.setOutput("right",false)
  os.shutdown
end
There. I wrote the entire program for you.
If you want more than one password…

term.clear()
term.setCursorPos(1,1)
password = "fghj"
password2 = "wert"
write("Password please: ")
input = read()
if input==password then
  print("Password correct!")
  rs.setOutput("left",true)
  sleep(4)
  rs.setOutput("left",false)
  print(Rebooting computer...")
  os.reboot()
elseif input==password2 then
  print("Password correct!")
  rs.setOutput("left",true)
  sleep(4)
  rs.setOutput("left",false)
  print(Rebooting computer...")
  os.reboot()
else
  print("Password incorrect!")
  rs.setOutput("right",true)
  sleep(1)
  rs.setOutput("right",false)
  os.shutdown
end
LlywMiner #4
Posted 12 July 2012 - 06:59 PM
@mister_s Thanks! I'll try the code!
@Lyqyd I will post whole program if mister_s code doesn't work