Advertisement
Guest User

Untitled

a guest
May 9th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.31 KB | None | 0 0
  1. --#Variables
  2. --##GLOBAL
  3. F16 = {}
  4. F16.author = "Adam Hellberg"
  5. F16.version = 0.1
  6. F16.longver = "Version 0.1 (1)"
  7. F16.errors = {}
  8. F16.errorcount = 0
  9. --#
  10. --##LOCAL
  11. local userbase = {}
  12. local user
  13. local password = {}
  14. local welmsgs = {}
  15. local loop = true
  16. --#
  17.  
  18. --#Set default values
  19. userbase.admin = "s3cr37p455"
  20. password.set = "null"
  21. password.check = "null"
  22. welmsgs[1] = "Welcome, press any key to login... "
  23. welmsgs[2] = "Hi, press any key to login... "
  24. welmsgs[3] = "Howdy, press button to login... "
  25. welmsgs[4] = "Yo, press da button to login... "
  26. --#
  27.  
  28. --#Functions
  29. function welmsg()
  30.     welmsgs.select = math.random(1, 4)
  31.     print(welmsgs[welmsgs.select])
  32. end
  33.  
  34. function createuser()
  35.     print("\nInput the username you want: ")
  36.     user = io.read()
  37.     print("\nInput the password you want: ")
  38.     password.set = io.read()
  39.     print("\nInput password again to check: ")
  40.     password.check = io.read()
  41.     if password.set == password.check then
  42.         print("\n\nSuccess! User created. Press any key to continue...")
  43.         userbase[user] = password.set
  44.         io.read()
  45.     else
  46.         print("\n\n\nAction failed. User not created (The passwords didn't match or you did something very wrong.)\nThe program will now exit...")
  47.         F16.errorcount = F16.errorcount + 1
  48.         F16.errors[F16.errorcount] = "Action failed. User not created (The passwords didn't match or you did something very wrong. The program will now exit..."
  49.         loop = false
  50.         io.read()
  51.     end
  52. end
  53.  
  54. function login()
  55.     print("\n\nPlease input username: ")
  56.     user = io.read()
  57.     if userbase[user] == nil then
  58.         print("\n\n\nError, user does not exist. Create it? Y/N... ")
  59.         user = io.read()
  60.         if user == "Y" or user == "y" or user == "yes" then
  61.             createuser()
  62.         else
  63.             user = "null"
  64.         end
  65.     else
  66.         print("\nPlease input password: ")
  67.         password.set = io.read()
  68.         if userbase[user] == password.set then
  69.             print("\n\nLogin successful! Press any key to restart... ")
  70.             io.read()
  71.             user = "null"
  72.             password.set = "null"
  73.         end
  74.     end
  75. end
  76.  
  77. function startloop()
  78.     while loop == true do
  79.         print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
  80.         welmsg()
  81.         io.read()
  82.         login()
  83.     end
  84. print("\n\n\nError occurred, press any key to exit... ")
  85. io.read()
  86. end
  87. --#
  88.  
  89.  
  90. --#Main
  91. startloop()
  92. --#DEBUGGING
  93. local debugcount
  94. for debugcount=1,20,1 do
  95.     print(F16.errors[debugcount]
  96. end
  97. --#
  98. --#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement