Advertisement
Alexr360

Password Screen

Feb 20th, 2024 (edited)
2,422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1. -- Set your desired password here
  2. local password = "your_password"
  3.  
  4. -- Function to clear the screen
  5. local function clearScreen()
  6.   term.clear()
  7.   term.setCursorPos(1, 1)
  8. end
  9.  
  10. -- Function to display login prompt
  11. local function displayLoginPrompt()
  12.   clearScreen()
  13.   print("Welcome to the secure system!")
  14.   print("Please enter the password to access:")
  15.   write("Password: ")
  16. end
  17.  
  18. -- Main function to check password
  19. local function checkPassword()
  20.   displayLoginPrompt()
  21.   local enteredPassword = read("*")
  22.  
  23.   if enteredPassword == password then
  24.     clearScreen()
  25.     print("Access granted!")
  26.     -- Your code for allowing access goes here
  27.     shell.run("Greeting")
  28.   else
  29.     clearScreen()
  30.     print("Incorrect password. Access denied.")
  31.     sleep(2)
  32.     checkPassword()  -- Retry password
  33.   end
  34. end
  35.  
  36. -- Run the main function
  37. checkPassword()
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement