password = "fuzzypaws"

os.pullEvent = os.pullEventRaw
shell.run("/boot/doAutoRuns")

--[[ Function declarations ]]--

function login(user)
	print("Welcome, " .. user)
	runFilesInDir("/boot/autorun/")
end

--[[ Begin Codey things ]]--

shell.run("/boot/splash")

term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.purple)
print("Kitty's Console")
term.setTextColor(colors.orange)
print("-- Keyboard Cat --")
term.setTextColor(colors.white)
failedCounter = 0
while(true) do
  print("Password: ")
  term.setTextColor(colors.lightGray)
  write("")
  reader = read("*")
  if(reader == password) then
  term.clear()
  term.setCursorPos(1,1)
  term.setTextColor(colors.white) 
 	login("cluekitty")
    break
  elseif(failedCounter >= 3) then
    term.setTextColor(colors.red)
    sleep(5)
    print("Too many failed passwords")
    sleep(10)
    print("Shutting down...")
    sleep(2)
    os.shutdown()
  else
    failedCounter = failedCounter + 1
    sleep(5)
    term.setTextColor(colors.red)
    print("Incorrect password")
    term.setTextColor(colors.white)
  end
end
