Advertisement
Alexr360

Password Screen

Feb 20th, 2024 (edited)
5,963
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. -- Print a line of dashes for aesthetics
  2. local function lineBreak()
  3.     local width, height = term.getSize()
  4.     for i = 1, width do
  5.       io.write("-")
  6.     end
  7.     io.write("\n")
  8. end
  9. -- Function to clear the screen
  10. local function clearScreen()
  11.     term.clear()
  12.     term.setCursorPos(1, 1)
  13. end
  14.  
  15. -- Set your desired password here
  16. local password = "your_password"
  17.  
  18. -- Function to clear the screen
  19. local function clearScreen()
  20.   term.clear()
  21.   term.setCursorPos(1, 1)
  22. end
  23.  
  24. -- Function to display login prompt
  25. local function displayLoginPrompt()
  26.   clearScreen()
  27.   print("Welcome to Monopoly OS by Monopoly Co.")
  28.   lineBreak()
  29.   print("Please enter the password to access:")
  30. end
  31.  
  32. -- Main function to check password
  33. local function checkPassword()
  34.   displayLoginPrompt()
  35.   local enteredPassword = read("*")
  36.  
  37.   if enteredPassword == password then
  38.     clearScreen()
  39.     print("Access granted!")
  40.     shell.run("Greeting")
  41.   else
  42.     clearScreen()
  43.     print("Incorrect password. Access denied.")
  44.     sleep(2)
  45.     checkPassword()
  46.   end
  47. end
  48.  
  49. -- Run the main function
  50. checkPassword()
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement