Advertisement
DefeatedPurpose

Rpg?

Nov 5th, 2018 (edited)
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.92 KB | None | 0 0
  1. -- RPG SOURCE
  2. -- DefeatedPurpose (Tohru / Kanna)
  3.  
  4. ver = "[BETA] 1.0"
  5. -- Standard wait func
  6. -- Setting up the wait function
  7. local function wait(tick)
  8.     local tick = tick or 1
  9.     local delay = os.time() + tick
  10.     while os.time() < delay do end
  11. end
  12.  
  13. -- Login Database
  14. NDatabase = {
  15.     "Owner_Test"
  16. }
  17. PDatabase = {
  18.     "Owner_Pass"
  19. }
  20. feedback = {
  21.     "Bad rpg"
  22. }
  23. Logged = false
  24. warn = "[CASE SENSITIVE]"
  25. print("Welcome to an RPG!")
  26. wait(1)
  27. print("You are running version: "..ver)
  28. wait(1)
  29. print("Do you have an existing account or would you like to create a new one?")
  30. wait(1)
  31. print("Options")
  32. print("1. Sign In")
  33. print("2. Sign Up")
  34. wait(1)
  35. a = io.read()
  36. a = string.lower(a)
  37. if a == "sign in" then
  38.     signingin = true
  39.     signingup = false
  40.     elseif a == "sign up" then
  41.     signingin = false
  42.     signingup = true
  43. end
  44. wait(1)
  45. if signingin then
  46.     print("Looks like you're signing in. Glad to have you back!")
  47.     wait(1)
  48.     print("Username? "..warn)
  49.     a = io.read()
  50.     for i,v in pairs(NDatabase) do
  51.         if a == v then
  52.             matched = true
  53.             else
  54.             matched = false
  55.         end
  56.     end
  57.     wait(1)
  58.     if matched then
  59.         print("Username found in our database.")
  60.     else
  61.     print("Username not found in our database.")
  62.     end
  63.     wait(1)
  64.     if matched then
  65.         print("Password? "..warn)
  66.         a = io.read()
  67.         for i,v in pairs(PDatabase) do
  68.             if a == v then
  69.                 matched2 = true
  70.                 else
  71.                 matched2 = false
  72.             end
  73.         end
  74.      end
  75.     wait(1)
  76.     if matched2 then
  77.         print("Login Success!")
  78.         Logged = true
  79.         else
  80.         print("Login Failed!")
  81.         Logged = true
  82.         wait(1)
  83.         print("Please restart the login process to try again.")
  84.    end
  85. end
  86. if signingup then
  87.     print("Thank you for your intrest in my RPG and I hope you enjoy your time playing!")
  88.     wait(1)
  89.     print("To begin, please type a username!")
  90.     a = io.read()
  91.     for i,v in pairs(NDatabase) do
  92.         if a == v then
  93.             taken = true
  94.             else
  95.             taken = false
  96.         end
  97.     end
  98.     wait(1)
  99.     if taken then
  100.         a = ""..a..""..math.random(231, 999)..""
  101.         print("Name already taken!")
  102.         print("Generated Name:")
  103.         print(a)
  104.         else
  105.         print("Chosen Name:")
  106.         print(a)
  107.     end
  108.     table.insert(NDatabase, a)
  109.     wait(1)
  110.     print("Choose a password")
  111.     a = io.read()
  112.     wait(1)
  113.     if #a > 5 then
  114.         print("Password too short!")
  115.         wait(1)
  116.         print("Generated Password:")
  117.         a = ""..a, math.random(1,9), math.random(1,9), math.random(1,9), math.random(1,9)..""
  118.         print(a)
  119.         else
  120.         print("Password Set.")
  121.     end
  122.     table.insert(PDatabase, a)
  123.     wait(1)
  124.     print("You may now proceed to the login stage!")
  125.     wait(1)
  126.     print("Username? "..warn)
  127.     a = io.read()
  128.     for i,v in pairs(NDatabase) do
  129.         if a == v then
  130.             matched = true
  131.             else
  132.             matched = false
  133.         end
  134.     end
  135.     wait(1)
  136.     if matched then
  137.         print("Username found in our database.")
  138.     else
  139.     print("Username not found in our database.")
  140.     end
  141.     wait(1)
  142.     if matched then
  143.         print("Password? "..warn)
  144.         a = io.read()
  145.         for i,v in pairs(PDatabase) do
  146.             if a == v then
  147.                 matched2 = true
  148.                 else
  149.                 matched2 = false
  150.             end
  151.         end
  152.      end
  153.     wait(1)
  154.     if matched2 then
  155.         print("Login Success!")
  156.         Logged = true
  157.         else
  158.         print("Login Failed!")
  159.         Logged = true
  160.         wait(1)
  161.         print("Please restart the login process to try again.")
  162.    end
  163. end
  164. wait(1)
  165. if Logged then
  166.     while true do
  167.     print("Welcome to the User Interface!")
  168.     wait(1)
  169.     print("Options:")
  170.     print("1. Log Out (Unsaved progress will be lost)")
  171.     print("2. Delete Account (Can't be undone.")
  172.     print("3. Explore [W.I.P.]")
  173.     a = io.read()
  174.     a = string.lower(a)
  175.     wait(1)
  176.     if a == "log out" then
  177.        print("Logging out..")
  178.        wait(3)
  179.        Logged = false
  180.        print("Logged out. Hope to see you back soon!")
  181.        break
  182.     end
  183.     if a == "delete account" then
  184.        print("Deleting account and all data related to it...")
  185.        -- Not set up yet so clears database entirely
  186.        NDatabase = nil
  187.        PDatabase = nil
  188.        wait(5)
  189.        Logged = false
  190.        print("Account has been deleted and you have been logged out, Please provide some feedback on why you have made this decision.")
  191.        a = io.read()
  192.        print("Thank you for your feedback.")
  193.        table.insert(feedback, a)
  194.        break
  195.     end
  196.     if a == "explore" then
  197.        print("You explore but find nothing.")
  198.        print("Probably because this function isn't set up yet. IDK?")
  199.     end
  200.     end
  201. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement