The problem with you trying to exit out using your admin password is that once your door script has stopped, your run command in your startup file is in a loop and so it will run it again, you can just remove the loop and have the run command. Since the main part of your door program is in a while loop it should keep running until you call error() (you could also just use return )
Also another tip, in your code for correct password (123) you should have it reset x to 1
Edit: I just remembered that cc has that pesky terminate keypress <_</> however you can avoid the termination by putting
local oldEve = os.pullEvent
os.pullEvent = os.pullEventRaw
at the top of your code, this is make it so the termination event will not workThen before you exit your script you can do
os.pullEvent = oldEve
to change it back to normal
And yet another edit: I noticed that the code already has the os.pullEventRaw, good, however it is a good idea to save the old pullEvent then return it to normal, so that still stands.
Ex:
Spoiler
while true do
shell.run("doorlock")
end
to
shell.run("doorlock")
and
if input == "123" then
term.clear()
term.setCursorPos(1,1)
textutils.slowWrite("The password entered was correct!")
sleep(1)
term.clear()
term.setCursorPos(1,1)
textutils.slowWrite("Opening Gate...")
rs.setOutput("back",true)
sleep(5)
rs.setOutput("back",false)
else if input == "1234" then
term.clear()
term.setCursorPos(1,1)
textutils.slowWrite("Admin password has been entered.")
sleep(1)
term.clear()
term.setCursorPos(1,1)
textutils.slowPrint("One moment...")
sleep(2)
term.clear()
term.setCursorPos(1,1)
error()
to
if input == "123" then
term.clear()
term.setCursorPos(1,1)
textutils.slowWrite("The password entered was correct!")
sleep(1)
term.clear()
term.setCursorPos(1,1)
textutils.slowWrite("Opening Gate...")
rs.setOutput("back",true)
sleep(5)
rs.setOutput("back",false)
x = 1 --Added so when the correct password is entered the incorrect counter resets
else if input == "1234" then
term.clear()
term.setCursorPos(1,1)
textutils.slowWrite("Admin password has been entered.")
sleep(1)
term.clear()
term.setCursorPos(1,1)
textutils.slowPrint("One moment...")
sleep(2)
term.clear()
term.setCursorPos(1,1)
os.pullEvent = oldEve --Change the pullEvent back to normal
return --You can use return instead of error() (Just better practice since there is no real error