Guest User

Untitled

a guest
May 26th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.23 KB | None | 0 0
  1. function payment()
  2.     userpath = ("currency/"..user)
  3.     moneyfile = io.open(userpath)
  4.     lol = moneyfile:read("*l")
  5.     mone1 = moneyfile:read("*l")
  6.     money = tonumber(mone1)
  7.     shell.run("clear")
  8.     print("")
  9.     print("")
  10.     print("       How many $ do you want to get?")
  11.     print("")
  12.     print("Amount in $: ")
  13.     print("            -------------------------")
  14.     term.setCursorPos(14, 5)
  15.     amount = read()
  16.     a = tonumber(amount)
  17.     if money < a then
  18.         print("\n       You dont have this much")
  19.         sleep(3)
  20.         payment()
  21.     elseif a < 0 then
  22.         print("\n       Must be a positive value")
  23.         sleep(3)
  24.         payment()
  25.     else
  26.         print("\n       Here you go, ", amount, "$")
  27.         sleep(3)
  28.         money = money - a
  29.         mone = tostring(money)
  30.         idfile:write(pass, "\n", mone)
  31.         exit()
  32.     end
  33. end
  34.  
  35. function newid()
  36.     shell.run("clear")
  37.     print("")
  38.     print("")
  39.     print("       Login: Username & password")
  40.     print("")
  41.     print("Username:")
  42.     print("         ------------------------")
  43.     print("Password: ")
  44.     print("         ------------------------")
  45.     print("Re-enter: ")
  46.     print("         ------------------------")
  47.     term.setCursorPos(11, 5)
  48.     user = read()
  49.     term.setCursorPos(11, 7)
  50.     pass = read("*")
  51.     term.setCursorPos(11, 9)
  52.     pass2 = read("*")
  53.     if pass == pass2 then
  54.         userpath = ("currency/"..user)
  55.         idfile = io.open(userpath)
  56.         idfile:write(pass)
  57.         idfile:close()
  58.     else
  59.         print("\n       Password mismatch")
  60.     end
  61. end
  62.  
  63. function id()
  64.     shell.run("clear")
  65.     print("")
  66.     print("")
  67.     print("       Login: Username & password")
  68.     print("")
  69.     print("Username:")
  70.     print("         ------------------------")
  71.     print("Password: ")
  72.     print("         ------------------------")
  73.     term.setCursorPos(11, 5)
  74.     user = read()
  75.     term.setCursorPos(11, 7)
  76.     pass = read("*")
  77.     userpath = ("currency/"..user)
  78.     if user == "/newuser" then
  79.         newid()
  80.     end
  81.     if fs.exists(userpath) then
  82.         idfile = io.open(userpath)
  83.         passcheck = idfile:read("*l")
  84.         idfile:close()
  85.     if passcheck == pass then
  86.         print("Logged in as ", user)
  87.         sleep(3)
  88.         payment()
  89.     else
  90.         print("\nWrong password and/or username")
  91.         sleep(3)
  92.         id()
  93.     end
  94.     else
  95.         print("\nUser does not exist, \ntype /newuser in the username field and leave the password field blank to create a new user")
  96.         lol = read("")
  97.         id()
  98.     end
  99. end
  100.  
  101. id()
Add Comment
Please, Sign In to add comment