Guest User

startup

a guest
Apr 29th, 2012
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.51 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. f = io.open("data.password", "r")
  3. password = f:read("*a")
  4. f:close()
  5. while true do
  6.   term.clear()
  7.   term.setCursorPos(1,1)
  8.   print("Enter password:")
  9.     local enteredpassword = read("*")
  10.   if enteredpassword ~= password then
  11.     print("Wrong password")
  12.     sleep(0.3)
  13.   else
  14.     print("Accepted")
  15.     sleep(1)
  16.    while true do
  17.     term.clear()
  18.     term.setCursorPos(1,1)
  19.     print("Security Terminal")
  20.     if (rs.getOutput("back") == true) then
  21.       print("Security system status: OFF")
  22.     else
  23.       print("Security system status: ON")
  24.     end
  25.     print("1. Toggle security system")
  26.     print("2. Change password")
  27.     print("3. Lock terminal")
  28.     local choice = read()
  29.     if choice == "1" then
  30.     if (rs.getOutput("back") == false) then
  31.       rs.setOutput("back",true)
  32.     else
  33.       rs.setOutput("back",false)
  34.     end
  35.       print("Toggling...")
  36.       sleep(1)
  37.     elseif choice == "2" then
  38.       term.clear()
  39.       term.setCursorPos(1,1)
  40.       print("Enter new password:")
  41.       local firstattempt = read("*")
  42.       print("Confirm new password:")
  43.       local secondattempt = read("*")
  44.       if firstattempt == secondattempt then
  45.         print("New password set")
  46.         password = firstattempt
  47.         f = io.open("data.password", "w")
  48.         f:write(password)
  49.         f:close()
  50.         sleep(1)
  51.       else
  52.         print("Passwords don't match")
  53.         sleep(0.6)
  54.       end
  55.     elseif choice == "3" then
  56.       break
  57.     end
  58.     end
  59.   end
  60. end
Advertisement
Add Comment
Please, Sign In to add comment