Advertisement
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
- pri = peripheral.wrap("left")
- function reqPin(req)
- rednet.send(PINMachine, req)
- id, ms = rednet.receive(60)
- if ms == nil then
- print("PIN Machine Offline After Trying For 60 Secodns")
- end
- return ms
- end
- function Menu()
- printMenu()
- input = read()
- if input == "5" then
- createAccount()
- elseif input == "4" then
- accPin()
- elseif input == "7" then
- printLogin()
- elseif input == "6" 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("[4] Change PIN")
- print()
- print("[5] Open Account")
- print("[6] Close Account")
- print("[7] Log Out")
- print("-------------------------")
- print()
- write(">> ")
- end
- function accPin()
- print()
- print("Please ask customer to insert card into reader")
- local res = reqPin("CARD")
- if res ~= nil then
- print("Account: "..res)
- accN = res
- else
- print("Please Input Manually")
- write("Account: ")
- accN = read()
- end
- print("Please ask customer to type old pin")
- oPIN = reqPin("PIN")
- rednet.send(ServerID, "PINCheck")
- rednet.send(ServerID, accN)
- rednet.send(ServerID, oPIN)
- id, conf = rednet.receive(30)
- if conf == "true" then
- conf = true
- elseif conf == "false" then
- conf = false
- end
- if conf == nil then
- printError("Server Offline")
- printError("Logging Off..")
- sleep(2)
- shell.run("startup")
- elseif conf then
- print("Correct PIN Entered")
- elseif not conf then
- print("Incorrect PIN Entered")
- sleep(1)
- Menu()
- else
- Menu()
- end
- while true do
- print("Please tell customer to enter new PIN")
- nPIN = reqPin("PIN")
- print("Please tell customer to confirm PIN")
- ntPIN = reqPin("PIN")
- if nPIN == ntPIN then
- break
- else
- print("PIN Numbers Don't Match")
- end
- end
- rednet.send(ServerID, "CPIN")
- rednet.send(ServerID, accN)
- rednet.send(ServerID, nPIN)
- print("PIN Changed")
- sleep(1)
- Menu()
- end
- function checkBalance()
- print("[1] Type Manually")
- print("[2] Insert Card")
- print()
- print("[3] Cancel")
- 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")
- elseif input == "3" then
- Menu()
- else
- checkBalance()
- 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()
- print()
- print("PIN Received")
- print()
- write("First: ")
- FN = read()
- write("Last: ")
- LN = read()
- FuN = FN .. " " .. LN
- rednet.send(ServerID, "CA")
- rednet.send(ServerID, DA)
- rednet.send(ServerID, PIN)
- rednet.send(ServerID, FuN)
- id, CN = rednet.receive()
- LFo = string.sub(CN, 13, 16)
- 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")
- fp = fs.open("printerEx", "r")
- pri.newPage()
- for i = 1, 10 do
- pri.setCursorPos(1, i)
- L = fp.readLine()
- if i == 1 then
- pri.write(L)
- elseif i == 2 then
- pri.write(L..FN)
- elseif i == 3 then
- pri.write(L..LN)
- elseif i == 4 then
- pri.write(L)
- elseif i == 5 then
- pri.write(L..DA)
- elseif i == 6 then
- pri.write(L..LFo)
- elseif i > 7 then
- pri.write(L)
- end
- end
- pri.endPage()
- 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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement