Posted 11 April 2013 - 11:01 AM
I have recently posted a topic for trying to fix this program but this is a completely new bug that, again, I cant fix. Making my lockup program more secure, I have added in a part to make a new file so the guessCount stays if someone trys to reboot it. Here is the code:
function lockUp()
os.pullEvent = os.pullEventRaw
local openGuessFile = io.open("guessCounter", "w")
file:write(guessesSoFarFile)
file:close()
local openGuessFile = io.open("guessCounter", "r")
local guessesSoFar = files:read("*n")
file:close
GUESSES_ALLOWED = 3
password = "Password1"
lockUpTime = 60
lockUpTimeLeft = lockUpTime
greeting = "Please verify that you have permission to access this ______: "
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..........")
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()
It says that something is wrong in the variables near the top of the function. Any help would be appreciated! Thank you.