Advertisement
Crysys

Account Login

Dec 17th, 2018
952
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.89 KB | None | 0 0
  1. while true do --Enter the loop
  2.   local accounts = { --use a table to define the usernames and their passwords
  3.     ["Alex"] = "password",
  4.   }
  5.  
  6.   function tReset() --formatting function for the terminal screen reset
  7.     term.clear()
  8.     term.setCursorPos(1,1)
  9.   end
  10.  
  11.   tReset()
  12.  
  13.   write("!!!Login Required!!!")
  14.   term.setCursorPos(1,3)
  15.   write("Enter username")
  16.   write("> ")
  17.   input_user = read() --read the user input in clear text
  18.  
  19.   write("Enter password")
  20.   write("> ")
  21.   input_pass = read("*") --read the user input using *'s to hide the entry
  22.  
  23.   if accounts[input_user] == input_pass then --check if the username/password matches the table
  24.     sleep(1)
  25.     tReset()
  26.     shell.run("menu") --move to our menu application
  27.     break --break from the loop in order to properly use the next program
  28.   else
  29.     tReset()
  30.     write("Incorrect Username/Password")
  31.   end
  32. end --end the loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement