Advertisement
Guest User

password

a guest
Feb 6th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.23 KB | None | 0 0
  1. local username
  2. local password
  3. local uninput
  4. local pwinput
  5. local input
  6. local redoutput = "top"
  7.  
  8. os.pullEvent = os.pullEventRaw
  9.  
  10. function stop(int)
  11.   sleep(int)
  12.   term.clear()
  13.   term.setCursorPos(1,1)
  14. end
  15.  
  16. function setcredentials()
  17.   print("Enter New Username:")
  18.   username = read()
  19.   print("Enter New Password:")
  20.   password = read("*")
  21.   print("Credentials Set")
  22.   stop(1)
  23.   choisemenu()
  24. end
  25.  
  26. function setpassword()
  27.   print("Enter Old Password:")
  28.   pwinput = read("*")
  29.     if pwinput == password then
  30.       print("Enter New Pasword:")
  31.       password = read("*")
  32.       print("Password Succesfully Changed")
  33.       stop(1)
  34.       choisemenu()
  35.     else
  36.       print("Incorrect Password\nTry Again")
  37.       stop(1)
  38.       setpassword()
  39.     end
  40. end
  41.  
  42. function checkcredentials()
  43.   print("Enter Username:")
  44.   uninput = read()
  45.   print("Enter Password:")
  46.   pwinput = read("*")
  47.   stop(0)
  48.     if uninput == username and pwinput == password then
  49.       print("Credentials Correct")
  50.       stop(1)
  51.       choisemenu()
  52.     else
  53.       print("Credentials Incorrect")
  54.       stop(1)
  55.       checkcredentials()
  56.     end
  57. end
  58.  
  59. function choisemenu()
  60.   print("Choises:\n1: Change Password\n2: Give Redstone Output\n3: Change Redstone Output Side\n4: Logout\n5: Reboot\n")
  61.   input = read()
  62.     if input == "1" then
  63.       stop(0)
  64.       setpassword()
  65.     elseif input == "2" then
  66.       stop(0)
  67.       rs.setOutput(redoutput, true)
  68.       sleep(5)
  69.       rs.setOutput(redoutput, false)
  70.       checkcredentials()
  71.     elseif input == "3" then
  72.       stop(0)
  73.       setredstone()
  74.     elseif input == "4" then
  75.       stop(0)
  76.       checkcredentials()
  77.     elseif input == "5" then
  78.       shell.run("reboot")
  79.     else
  80.       stop(0)
  81.       print("Input Incorrect")
  82.       stop(1)
  83.       choisemenu()
  84.     end
  85. end
  86.  
  87. function firstrun()
  88.   print("Copyright RIPsac 2017\n\nWelcome to the RepsacPasswordLock programm\n\n(Default Redstone Side Output = top)\n\nPress any key to setup programm")
  89.   os.pullEvent("key")
  90.   stop(1)
  91.   setcredentials()
  92. end
  93.  
  94. function setredstone()
  95.   print("On which side do you want your redstone output?\nInput: left, right, back, front, bottom, top")
  96.   redoutput = read()
  97.   stop(1)
  98.   choisemenu()
  99. end
  100.  
  101. stop(0)
  102. firstrun()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement