JordanC

(new) - Highly Secure Door Lock

Aug 13th, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.37 KB | None | 0 0
  1. --FUNCTIONS
  2. function clearScreen(x,y)
  3.   term.clear()
  4.   term.setCursorPos(x,y)
  5. end
  6.  
  7. function printCenter(str, ypos, mode)
  8.   local w,h = term.getSize()
  9.   term.setCursorPos(w/2 - #str/2, ypos)
  10.   if mode == "s" then
  11.     textutils.slowPrint(str)
  12.   elseif mode == "f" then
  13.     print(str)
  14.   end
  15. end
  16.  
  17. i = 3
  18. function ReadPass()
  19.   if input == "25439w4hjd134673" then
  20.     clearScreen(1,1)
  21.     printCenter("CODE",7,s)
  22.     printCenter("CORRECT",8,s)
  23.     printCenter("Welcome - Jordan DG Chandanais",9,s)
  24.     sleep(1)
  25.     rs.setOutput("back", false)
  26.     sleep(4)
  27.     rs.setOutput("back", true)
  28.   else
  29.     printCenter("invalid password",9,f)
  30.     MainGUI(2)
  31.   end
  32. end
  33.  
  34. function passGUI()
  35.   term.setCursorPos(15,8)
  36.   write("Password: ")
  37.   input = read("*")
  38.   ReadPass()
  39. end
  40.  
  41. function MainGUI(x)
  42.   if x == 1 then
  43.     clearScreen(1,1)
  44.     printCenter("Goverment",1,s)
  45.     printCenter("Research and Development",2,s)
  46.     printCenter("Facility - GHOST",3,s)
  47.     sleep(2)
  48.     passGUI()
  49.   elseif x == 2 then
  50.     i = i - 1
  51.     clearScreen(1,1)
  52.     printCenter("Goverment",1,f)
  53.     printCenter("Reasearch and Development",2,f)
  54.     printCenter("Facility - GHOST",3,f)
  55.     printCenter(i.." attempts remaining",9,f)
  56.     if i == 0 then
  57.       os.reboot()
  58.     else
  59.       passGUI()
  60.     end
  61.   end
  62. end
  63.  
  64. --CODE
  65. rs.setOutput("back", true)
  66. clearScreen(1,1)
  67. MainGUI(1)
Advertisement
Add Comment
Please, Sign In to add comment