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

Help With My Password Program

Started by TylerDude447, 27 March 2018 - 11:36 PM
TylerDude447 #1
Posted 28 March 2018 - 01:36 AM
I'm writing a password program and i would like to have an infinite loop in the background checking for a disk that has a 'backdoor' password on it just in-case i forget the password i set it to (It happens a lot) anyways i have no idea about how to do since the program halts when given the read() prompt. All help is appreciated thanks~

code:

os.pullEvent = os.pullEventRaw

term.clear()
term.setCursorPos(1,1)
print("Please login!\n")

term.write("Password: ")
input = read("*")
if input == "lolfun!" then
print("\nPassword Correct!")
sleep(2)
term.clear()
term.setCursorPos(1,1)
print("YourOS")
else
print("\nPassword Incorrect!")
sleep(2)
os.reboot()
end
KingofGamesYami #2
Posted 28 March 2018 - 05:08 AM
1) rebooting is bad. Avoid doing that whenever possible.

2) The parallel API is likely what you're after, though for your purpose it'd probably be fine to just check it after an incorrect pass is entered.
TylerDude447 #3
Posted 30 March 2018 - 01:57 AM
how exactly do you use the parallel API
KingofGamesYami #4
Posted 30 March 2018 - 02:32 AM
Have a tutorial. Or just check the wiki.