Advertisement
PrinceOfCookies

os/.secCheck

Jan 25th, 2023 (edited)
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.74 KB | Source Code | 0 0
  1. local tscp = term.setCursorPos -- set cursor pos
  2. local tcl = term.clearLine -- clear line
  3. local tw = term.write -- write
  4. local tc = term.clear -- clear
  5. local tgs = term.getSize -- get size
  6. local tstc = term.setTextColor
  7. local tsbc = term.setBackgroundColor
  8.  
  9. tc()
  10. tscp(1,1)
  11. print("Please enter the password to access cmd")
  12. print("To return to main menu, type `back`")
  13. print("===================================================")
  14. local input = read("*")
  15.  
  16. local w, h = tgs()
  17.  
  18. local red = colors.red
  19. local green = colors.green
  20. local white = colors.white
  21. local black = colors.black
  22.  
  23. local function displayAccessGranted()
  24.     tc()
  25.     local message = "Access Granted"
  26.     local x, y = math.floor(w / 2) - math.floor(string.len(message) / 2), math.floor(h / 2)
  27.     tsbc(green)
  28.     for i = 1, h do
  29.     tscp(1, i)
  30.         tw("                                                                                              ")
  31.     end
  32.     tscp(x, y)
  33.     tstc(black)
  34.     print(message)
  35.     sleep(1)
  36.     tsbc(black)
  37.     tc()
  38.     tscp(1,1)
  39. end
  40.  
  41. local function displayAccessDenied()
  42.     sleep(0.2)
  43.     term.clear()
  44.     local message = "Access Denied"
  45.     local x, y = math.floor(w / 2) - math.floor(string.len(message) / 2), math.floor(h / 2)
  46.     tsbc(red)
  47.     for i = 1, h do
  48.     tscp(1, i)
  49.         tw("                                                                                              ")
  50.     end
  51.     tscp(x, y)
  52.     tstc(black)
  53.     print(message)
  54.     sleep(1)
  55.     tsbc(black)
  56.     tc()
  57.     shell.run(".menu")
  58. end
  59.  
  60. if input == "124" then
  61.     sleep(0.2)
  62.     displayAccessGranted()
  63.     sleep(0.2)
  64.     tstc(white)
  65.     shell.run("os/.command")
  66. elseif input == "back" then
  67.     shell.run(".menu")
  68. else
  69.     displayAccessDenied()
  70. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement