Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local oldPullEvent = os.pullEvent
- os.pullEvent = os.pullEventRaw
- breakclause = true
- while breakclause do
- local file = fs.open(usernamedata,"r")
- local data = file.readAll()
- file.close()
- return textutils.unserialize(data)
- file = fs.open(passworddata,"r")
- file.close()
- return textutils.unserialize(data)
- file = fs.open(amountdata,"r")
- file.close()
- return textutils.unserialize(data)
- term.clear()
- term.setCursorPos(1,1)
- print("Welcome to VolcBank's Automated Teller System.")
- print("Please Select an option.")
- print("[1] Login")
- print("[2] Create a New Account")
- local startinput = read()
- if startinput == "CactiJammer" then
- print("Terminated")
- breakclause = false
- elseif startinput == "1" then
- term.clear()
- term.setCursorPos(1,1)
- print("Please Login Below.")
- write("Username: ")
- user = read()
- write("Password: ")
- pass = read("*")
- for i,v in ipairs(usernames) do
- if user == v then
- validuser = true
- end
- if validuser == true then
- if pass == passwords[i] then
- print("Logging in...")
- sleep(1)
- while true do
- term.clear()
- term.setCursorPos(1,1)
- print("What would you like to do today, "..usernames[i].."?")
- print("[1] Check Amount in Account")
- print("[2] Deposit")
- print("[3] Withdraw")
- print("[4] Change Password")
- print("[5] Logout")
- local input2 = read()
- if input2 == "1" then
- term.clear()
- term.setCursorPos(1,1)
- print("Amount in Account: "..amounts[i].."IC.")
- print("To deposit or withdraw, please return to the main page and select their corresponding options.")
- sleep(3)
- textutils.slowPrint("Returning to main page...")
- sleep(2)
- elseif input2 == "2" then
- term.clear()
- term.setCursorPos(1,1)
- print("How much would you like to deposit?")
- depamt = read()
- amounts[i] = amounts[i]+depamt
- print("Please place amount of IC deposited into chest above. When finished, type \"1\".")
- local depositans = read()
- if depositans == "1" then
- for num=1,depamt do
- rs.setOutput("back",true)
- sleep(1)
- rs.setOutput("back",false)
- num=num+1
- end
- sleep(1)
- print("You now have "..amounts[i].."IC in your account.")
- sleep(2)
- textutils.slowPrint("Returning to main page...")
- sleep(2)
- end
- elseif input2 == "3" then
- term.clear()
- term.setCursorPos(1,1)
- print("How much would you like to withdraw?")
- wdamt = read()
- if amounts[i]-wdamt ~= 0 then
- print("Error: withdrawal amount is less than amount in account. Please enter a different amount.")
- wdamt = read()
- else
- amounts[i] = amounts[i]-wdamt
- for num = 1,wdamt do
- rs.setOutput("bottom",true)
- sleep(1)
- rs.setOutput("bottom",false)
- num=num+1
- end
- sleep(1)
- print("You now have "..amounts[i].."IC in your account.")
- sleep(3)
- textutils.slowPrint("Returning to main page...")
- sleep(2)
- end
- elseif input2 == "4" then
- term.clear()
- term.setCursorPos(1,1)
- write("Enter your current password: ")
- currpass = read("*")
- if currpass == passwords[i] then
- write("Enter new password: ")
- newpass = read("*")
- write("Re-enter new password: ")
- newpass2 = read("*")
- if newpass == newpass2 then
- passwords[i] = newpass
- print("Password changed. Please login with your new details.")
- sleep(3)
- os.reboot()
- else
- print("New passwords do not match.")
- sleep(1)
- end
- else
- print("Password is incorrect. Please re-enter password.")
- sleep(3)
- end
- elseif input2 == "5" then
- save(usernames,usernamedata)
- save(passwords,passworddata)
- save(amounts.amountdata)
- print("Thank you for banking with VolcBank.")
- sleep(3)
- os.reboot()
- else
- print("Error: invalid command.")
- sleep(1)
- end
- end
- else
- print("Invalid username or password. Please try again.")
- sleep(2)
- end
- else
- print("Error: user not found.")
- sleep(2)
- end
- end
- elseif startinput == "2" then
- while true do
- term.clear()
- term.setCursorPos(1,1)
- print("Thank you for choosing VolcBank. Enter your details below.")
- write("Username: ")
- newuser = read()
- write("Password: ")
- newuserpass = read("*")
- for i,v in ipairs(usernames) do
- if newuser == v then
- print("Error. Username already taken.")
- sleep(2)
- else
- table.insert(usernames,newuser)
- table.insert(passwords,newuserpass)
- table.insert(amounts,64)
- save(usernames,usernamedata)
- save(passwords,passworddata)
- save(amounts,amountdata)
- print("New account created. Please login with new details to enter account.")
- sleep(3)
- os.reboot()
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement