Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- User = " "
- ServerID = 13
- rednet.open("top")
- PINMachine = 33
- function Menu()
- printMenu()
- input = read()
- if input == "4" then
- createAccount()
- elseif input == "6" then
- printLogin()
- elseif input == "5" then
- closeAccount()
- elseif input == "1" then
- accDeposit()
- elseif input == "2" then
- accWithdraw()
- elseif input == "3" then
- checkBalance()
- else
- Menu()
- end
- end
- function printMenu()
- clear()
- print("Logged In: "..User)
- print()
- print("[1] Account Deposit")
- print("[2] Account Withdrawal")
- print("[3] Check Balance")
- print()
- print("[4] Open Account")
- print("[5] Close Account")
- print("[6] Log Out")
- print("-------------------------")
- print()
- write(">> ")
- end
- function checkBalance()
- print("[1] Type Manually")
- print("[2] Insert Card")
- print()
- write(">> ")
- input = read()
- if input == "1" then
- write("Account: ")
- Acc = read()
- elseif input == "2" then
- while not disk.isPresent("bottom") do sleep(0.01) end
- Acc = disk.getLabel("bottom")
- disk.eject("bottom")
- end
- rednet.send(ServerID, "ChkBal")
- rednet.send(ServerID, Acc)
- id, Bal = rednet.receive()
- tonumber(Bal)
- if Bal ~= "BalF" then
- print("Balance: D$"..Bal)
- sleep(3)
- Menu()
- elseif Bal == "BalF" then
- print("Invalid Acccount Number")
- sleep(2)
- Menu()
- end
- end
- function accWithdraw()
- print("[1] Type Manually")
- print("[2] Insert Card")
- print()
- write(">> ")
- input = read()
- if input == "1" then
- write("Account: ")
- Ac = read()
- elseif input == "2" then
- while not disk.isPresent("bottom") do sleep(0.01) end
- Ac = disk.getLabel("bottom")
- print("Account: "..Ac)
- end
- rednet.send(PINMachine, "PIN")
- id, PIN = rednet.receive()
- write("Amount: D$")
- Am = read()
- rednet.send(ServerID, "AW")
- rednet.send(ServerID, Ac)
- rednet.send(ServerID, PIN)
- rednet.send(ServerID, Am)
- id, Co = rednet.receive()
- if Co == "WiT" then
- print("Withdrew D$"..Am)
- sleep(2)
- Menu()
- elseif Co == "NB" then
- print("Not Enough Funds")
- sleep(2)
- Menu()
- elseif Co == "AcF" then
- print("Account Does not Exist")
- sleep(1)
- Menu()
- end
- end
- function accDeposit()
- print("[1] Type Manually")
- print("[2] Insert Card")
- print()
- write(">> ")
- input = read()
- if input == "1" then
- write("Account Number: ")
- Card = read()
- elseif input == "2" then
- while not disk.isPresent("bottom") do sleep(0.01) end
- Card = disk.getLabel("bottom")
- disk.eject("bottom")
- if Card ~= nil then
- print("Account Number: "..Card)
- else
- print("Foreign Object Inserted")
- sleep(3)
- Menu()
- end
- end
- write("Amount: ")
- Am = read()
- rednet.send(ServerID, "AD")
- rednet.send(ServerID, Card)
- rednet.send(ServerID, Am)
- id, msg = rednet.receive()
- if msg == "DT" then
- print("Deposited D$"..Am.." to Account "..Card)
- sleep(2)
- Menu()
- elseif msg == "DF" then
- print("Invalid Account")
- sleep(2)
- Menu()
- end
- end
- function closeAccount()
- print("Close Account")
- print()
- print("[1] Type Manually")
- print("[2] Insert Card")
- write(">> ")
- input = read()
- if input == "1" then
- write("Account Number: ")
- Card = read()
- elseif input == "2" then
- while not disk.isPresent("bottom") do sleep(0.01) end
- Card = disk.getLabel("bottom")
- print("Account Number: "..Card)
- disk.eject("bottom")
- else
- closeAccount()
- end
- rednet.send(PINMachine, "PIN")
- print("Tell the Customer to Enter their PIN")
- id, PIN = rednet.receive()
- rednet.send(ServerID, "RA")
- rednet.send(ServerID, Card)
- rednet.send(ServerID, PIN)
- id, msg = rednet.receive()
- if msg == "RT" then
- print("Successfuly Removed Account "..Card)
- sleep(2)
- elseif msg == "RF" then
- print("Invalid PIN Entered")
- sleep(2)
- Menu()
- elseif msg == "FA" then
- print("Invalid Account Number")
- sleep(2)
- Menu()
- end
- print()
- print("[1] Blank Card")
- print("[2] Return")
- input = read()
- if input == "1" then
- print("Insert Written Card")
- while not disk.isPresent("bottom") do sleep(0.01) end
- disk.setLabel("bottom")
- disk.eject("bottom")
- Menu()
- elseif input == "2" then
- Menu()
- else
- Menu()
- end
- end
- function createAccount()
- write("Deposit Amount: ")
- DA = read()
- rednet.send(PINMachine, "PIN")
- print("Tell the Customer to Enter PIN")
- id, PIN = rednet.receive()
- rednet.send(ServerID, "CA")
- rednet.send(ServerID, DA)
- rednet.send(ServerID, PIN)
- id, CN = rednet.receive()
- print("Account Opened")
- print("Please Insert Blank Card")
- while not disk.isPresent("bottom") do sleep(0.01) end
- disk.setLabel("bottom", tostring(CN))
- disk.eject("bottom")
- Menu()
- end
- function checkLogin()
- print("Checking Login..")
- rednet.send(ServerID, "TrmChk")
- rednet.send(ServerID, User)
- rednet.send(ServerID, Pass)
- id, Msg = rednet.receive()
- if Msg == "True" then
- print("Welcome "..User)
- sleep(1)
- Menu()
- elseif Msg == "False" then
- print("Invalid User/Password")
- sleep(2)
- printLogin()
- end
- end
- function printLogin()
- clear()
- print("Super's Bank Terminal")
- write("Username: ")
- User = read()
- write("Password: ")
- Pass = read("*")
- checkLogin()
- end
- printLogin()
Add Comment
Please, Sign In to add comment