Posted 05 April 2013 - 01:54 PM
I am new to computercraft (started on the 3rd of April this year) and I have spent about an hour making and debuging this program;
Also, just to confirm, does the " os.pullEvent = os.pullEventRaw" line prevent Ctrl + T?
function lockUp()
os.pullEvent = os.pullEventRaw --DO NOT CHANGE THIS!!! It protects the program from termination
GUESSES_ALLOWED = 3 --Don't raise this too high!!!
guessesSoFar = 0 --Keep this at 0!!!
password = "Password1" --What you want the password to be
lockUpTime = 60 --Upon failing password however many times max is set to, this is how long it will lock for
lockUpTimeLeft = lockUpTime --Leave this!!!
greeting = "Please verify that you have permission to access this ______: " --What will your computer's message be?
while guessesSoFar < GUESSES_ALLOWED do
term.clear()
term.setCursorPos(1, 1)
textutils.slowPrint(greeting)
textutils.slowPrint("Attempts remaining: "..GUESSES_ALLOWED - guessesSoFar)
textutils.slowPrint("Enter password: ")
passwordGuesses = read("*")
if guess == password then
term.clear()
term.setCursorPos(1, 1)
textutils.slowPrint("Password Correct!")
textutils.slowPrint("Access Granted!!!")
textutils.slowPrint("..........Loading..........")
end
else
guessesSoFar = guessesSoFar + 1
term.clear()
term.setCursorPos(1, 1)
textutils.slowPrint("Password Incorrect!")
textutils.slowPrint("Access Denied!!!")
textutils.slowPrint("..........Locking..........")
end
end
while lockUpTimeLeft > 0 do
term.clear()
term.setCursorPos(1, 1)
print("Number of password guesses exceeded.")
print()
print("Locking terminal for"..lockUpTimeLeft.." seconds.")
lockUpTimeLeft = lockUpTimeLeft - 1
sleep(1)
end
if lockUpTimeLeft == 0 then
term.clear()
term.setCursorPos(1, 1)
textutils.slowPrint("..........Rebooting program..........")
lockUp()
end
end
lockUp()
but when I think im done with debugging it, I run into a problem that I don't know how to fix. When I try to run it, it tells me that it expects a end to the function at line 37, but that would cut off the function half way through and would prevent the program working. If anybody can check this out for me then that would be appreciated.Also, just to confirm, does the " os.pullEvent = os.pullEventRaw" line prevent Ctrl + T?