Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function payment()
- userpath = ("currency/"..user)
- moneyfile = io.open(userpath)
- lol = moneyfile:read("*l")
- mone1 = moneyfile:read("*l")
- money = tonumber(mone1)
- shell.run("clear")
- print("")
- print("")
- print(" How many $ do you want to get?")
- print("")
- print("Amount in $: ")
- print(" -------------------------")
- term.setCursorPos(14, 5)
- amount = read()
- a = tonumber(amount)
- if money < a then
- print("\n You dont have this much")
- sleep(3)
- payment()
- elseif a < 0 then
- print("\n Must be a positive value")
- sleep(3)
- payment()
- else
- print("\n Here you go, ", amount, "$")
- sleep(3)
- money = money - a
- mone = tostring(money)
- idfile:write(pass, "\n", mone)
- exit()
- end
- end
- function newid()
- shell.run("clear")
- print("")
- print("")
- print(" Login: Username & password")
- print("")
- print("Username:")
- print(" ------------------------")
- print("Password: ")
- print(" ------------------------")
- print("Re-enter: ")
- print(" ------------------------")
- term.setCursorPos(11, 5)
- user = read()
- term.setCursorPos(11, 7)
- pass = read("*")
- term.setCursorPos(11, 9)
- pass2 = read("*")
- if pass == pass2 then
- userpath = ("currency/"..user)
- idfile = io.open(userpath)
- idfile:write(pass)
- idfile:close()
- else
- print("\n Password mismatch")
- end
- end
- function id()
- shell.run("clear")
- print("")
- print("")
- print(" Login: Username & password")
- print("")
- print("Username:")
- print(" ------------------------")
- print("Password: ")
- print(" ------------------------")
- term.setCursorPos(11, 5)
- user = read()
- term.setCursorPos(11, 7)
- pass = read("*")
- userpath = ("currency/"..user)
- if user == "/newuser" then
- newid()
- end
- if fs.exists(userpath) then
- idfile = io.open(userpath)
- passcheck = idfile:read("*l")
- idfile:close()
- if passcheck == pass then
- print("Logged in as ", user)
- sleep(3)
- payment()
- else
- print("\nWrong password and/or username")
- sleep(3)
- id()
- end
- else
- print("\nUser does not exist, \ntype /newuser in the username field and leave the password field blank to create a new user")
- lol = read("")
- id()
- end
- end
- id()
Add Comment
Please, Sign In to add comment