r/ComputerCraft • u/afjaf • Dec 24 '17
simple Door Lock Problem
i copied some youtuber's code to make a simple passworded lock, and wanted to try and add a message if you put the incorrect password. any help on how to do that would be appreciated.
Code:
` while true do
term.setBackgroundColor(colors.blue)
term.clear()
term.setCursorPos(1, 1)
print("Enter password:")
local input = read("x")
if input == "1234" then
redstone.setOutput("right", true)
print("Access granted. Door opening...")
sleep(5)
redstone.setOutput("right", false)
print("Incorrect password, try again.")
end
end`
1
Upvotes
3
u/ImNotADeer Dec 24 '17 edited Dec 24 '17
If I understood your question correctly, what you need is the "else" statement. I also reorganized a little :)
edit: Added "sleep(2)" after printing the WRONG_MESSAGE so that it is displayed for two seconds before clearing the terminal again