Guest User

eBank

a guest
Jun 9th, 2014
644
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.01 KB | None | 0 0
  1. local acct = ""
  2. local interAcct = ""
  3. local name = ""
  4. local interName = ""
  5. local pass = ""
  6. local interPass = ""
  7. local muny = ""
  8. local interMuny = ""
  9. local inp = ""
  10. local acct2 = ""
  11. local name2 = ""
  12. local pass2 = ""
  13. local muny2 = ""
  14.  
  15. while true do
  16.  
  17. term.clear()
  18. term.setCursorPos(1,1)
  19. write("Please place your ")
  20. term.setTextColor(colors.red)
  21. write("Electronic Banking Card")
  22. term.setTextColor(colors.white)
  23. print(" in the disk drive.")
  24.  
  25. if disk.isPresent("left")==true then
  26.   if fs.exists("disk/acc") then
  27.     term.clear()
  28.     term.setCursorPos(1,1)
  29.     print("Please enter the account you wish to access.")
  30.     write("Account: ")
  31.     acct = read()
  32.     if fs.exists("disk/acc/"..acct..".txt") then
  33.       h = fs.open("disk/acc/"..acct..".txt", "r")
  34.       name = h.readLine()
  35.       pass = h.readLine()
  36.       muny = h.readLine()
  37.       h.close()
  38.       term.clear()
  39.       term.setCursorPos(1,1)
  40.       write("Please enter your password: ")
  41.       inp = read("*")
  42.       if inp==pass then
  43.         while inp~="" do
  44.           term.clear()
  45.           term.setCursorPos(1,1)
  46.           print("Welcome, "..name..". Your account currently has $"..muny..". What would you like to do?")
  47.           print("a) Withdraw from internal account")
  48.           print("b) Deposit from external account")
  49.           print("c) Make an internal payment to another account")
  50.           print("d) Create a new internal account")
  51.           print("e) Create a new external account")
  52.           print("f) Exit")
  53.           inp = read()
  54.           if inp=="a" then
  55.             term.clear()
  56.             term.setCursorPos(1,1)
  57.             print("Please state the internal account you wish to access: ")
  58.             write("Internal Account: ")
  59.             interAcct = read()
  60.             if fs.exists("acc/"..interAcct..".txt") then
  61.               iA = fs.open("acc/"..interAcct..".txt", "r")
  62.               interName = iA.readLine()
  63.               interPass = iA.readLine()
  64.               interMuny = iA.readLine()
  65.               iA.close()
  66.               term.clear()
  67.               term.setCursorPos(1,1)
  68.               write("Please enter this account's password: ")
  69.               inp = read("*")
  70.               if inp==interPass then
  71.                 term.clear()
  72.                 term.setCursorPos(1,1)
  73.                 print("This account belongs to "..interName..", and currently has $"..interMuny..". How much money would you like to withdraw from this internal account?")
  74.                 write("$")
  75.                 inp = read()
  76.                 if inp-0 > interMuny-0 then
  77.                   term.clear()
  78.                   term.setCursorPos(1,1)
  79.                   print("The internal account accessed has insufficient funds.")
  80.                   sleep(3)
  81.                   term.clear()
  82.                   term.setCursorPos(1,1)
  83.                 elseif inp-0 == 0 or inp-0 < 0 then
  84.                   term.clear()
  85.                   term.setCursorPos(1,1)
  86.                   print("You must withdraw $0.01 or more.")
  87.                   sleep(3)
  88.                   term.clear()
  89.                   term.setCursorPos(1,1)
  90.                 else
  91.                   muny = (muny-0) + (inp-0)
  92.                   interMuny = (interMuny-0) - (inp-0)
  93.                   local w = fs.open("disk/acc/"..acct..".txt", "w")
  94.                   w.writeLine(name)
  95.                   w.writeLine(pass)
  96.                   w.writeLine(muny)
  97.                   w.close()
  98.                   local iAW = fs.open("acc/"..interAcct..".txt", "w")
  99.                   iAW.writeLine(interName)
  100.                   iAW.writeLine(interPass)
  101.                   iAW.writeLine(interMuny)
  102.                   iAW.close()
  103.                   term.clear()
  104.                   term.setCursorPos(1,1)
  105.                   print("Transaction Complete.")
  106.                   sleep(3)
  107.                   term.clear()
  108.                   term.setCursorPos(1,1)
  109.                 end
  110.               else
  111.                 term.clear()
  112.                 term.setCursorPos(1,1)
  113.                 print("Access Denied.")
  114.                 sleep(3)
  115.                 term.clear()
  116.                 term.setCursorPos(1,1)
  117.               end
  118.             else
  119.               term.clear()
  120.               term.setCursorPos(1,1)
  121.               print("That internal account does not exist.")
  122.               sleep(3)
  123.               term.clear()
  124.               term.setCursorPos(1,1)
  125.             end
  126.           elseif inp=="b" then
  127.             term.clear()
  128.             term.setCursorPos(1,1)
  129.             print("Please enter the account that you would like to deposit money into.")
  130.             write("Internal Account: ")
  131.             interAcct = read()
  132.             if fs.exists("acc/"..interAcct..".txt") then
  133.               iA = fs.open("acc/"..interAcct..".txt", "r")
  134.               interName = iA.readLine()
  135.               interPass = iA.readLine()
  136.               interMuny = iA.readLine()
  137.               iA.close()
  138.               term.clear()
  139.               term.setCursorPos(1,1)
  140.               print("This account belongs to "..interName..". Would you like to deposit to this account?")
  141.               print("a) Yes.")
  142.               print("b) No.")
  143.               inp = read()
  144.               if inp=="a" then
  145.                 term.clear()
  146.                 term.setCursorPos(1,1)
  147.                 print("How much money would you like to deposit into the account?")
  148.                 write("$")
  149.                 inp = read()
  150.                 if inp-0 == 0 or inp-0 < 0 then
  151.                   term.clear()
  152.                   term.setCursorPos(1,1)
  153.                   print("You must deposit $0.01 or more.")
  154.                   sleep(3)
  155.                   term.clear()
  156.                   term.setCursorPos(1,1)
  157.                 elseif inp-0 > muny-0 then
  158.                   term.clear()
  159.                   term.setCursorPos(1,1)
  160.                   print("You have insufficient funds.")
  161.                   sleep(3)
  162.                   term.clear()
  163.                   term.setCursorPos(1,1)
  164.                 else
  165.                   term.clear()
  166.                   term.setCursorPos(1,1)
  167.                   muny = (muny-0) - (inp-0)
  168.                   interMuny = (interMuny-0) + (inp-0)
  169.                   w = fs.open("disk/acc/"..acct..".txt", "w")
  170.                   w.writeLine(name)
  171.                   w.writeLine(pass)
  172.                   w.writeLine(muny)
  173.                   w.close()
  174.                   iAW = fs.open("acc/"..interAcct..".txt", "w")
  175.                   iAW.writeLine(interName)
  176.                   iAW.writeLine(interPass)
  177.                   iAW.writeLine(interMuny)
  178.                   iAW.close()
  179.                   print("Transaction complete.")
  180.                   sleep(3)
  181.                   term.clear()
  182.                   term.setCursorPos(1,1)
  183.                 end
  184.               elseif inp=="b" then
  185.                 term.clear()
  186.                 term.setCursorPos(1,1)
  187.               else
  188.                 term.clear()
  189.                 term.setCursorPos(1,1)
  190.                 print("That was not an option.")
  191.                 sleep(3)
  192.                 term.clear()
  193.                 term.setCursorPos(1,1)
  194.               end
  195.             else
  196.               term.clear()
  197.               term.setCursorPos(1,1)
  198.               print("That internal account does not exist.")
  199.               sleep(3)
  200.               term.clear()
  201.               term.setCursorPos(1,1)
  202.             end
  203.           elseif inp=="c" then
  204.             term.clear()
  205.             term.setCursorPos(1,1)
  206.             print("From which internal account would you like to make the payment?")
  207.             write("Internal Account: ")
  208.             interAcct = read()
  209.             if fs.exists("acc/"..interAcct..".txt")==true then
  210.               iA = fs.open("acc/"..interAcct..".txt", "r")
  211.               interName = iA.readLine()
  212.               interPass = iA.readLine()
  213.               interMuny = iA.readLine()
  214.               iA.close()
  215.               term.clear()
  216.               term.setCursorPos(1,1)
  217.               write("Please enter your password: ")
  218.               inp = read("*")
  219.               if inp==interPass then
  220.                 term.clear()
  221.                 term.setCursorPos(1,1)
  222.                 print("Welcome, "..interName..". You have $"..interMuny..". What account would you like to make a payment to?")
  223.                 write("Internal Account: ")
  224.                 local interAccte = read()
  225.                 if fs.exists("acc/"..interAccte..".txt") then
  226.                   iAe = fs.open("acc/"..interAccte..".txt", "r")
  227.                   local interNamee = iAe.readLine()
  228.                   local interPasse = iAe.readLine()
  229.                   local interMunye = iAe.readLine()
  230.                   iAe.close()
  231.                   term.clear()
  232.                   term.setCursorPos(1,1)
  233.                   print("This account belongs to "..interNamee..". Is this who you would like to pay?")
  234.                   print("a) Yes.")
  235.                   print("b) No.")
  236.                   inp = read()
  237.                   if inp=="a" then
  238.                     term.clear()
  239.                     term.setCursorPos(1,1)
  240.                     print("How much would you like to pay?")
  241.                     write("$")
  242.                     inp = read()
  243.                     if inp-0 > interMuny-0 then
  244.                       term.clear()
  245.                       term.setCursorPos(1,1)
  246.                       print("Your account has insufficient funds.")
  247.                       sleep(3)
  248.                       term.clear()
  249.                       term.setCursorPos(1,1)
  250.                     elseif inp-0 == 0 or inp-0 < 0 then
  251.                       term.clear()
  252.                       term.setCursorPos(1,1)
  253.                       print("You may only make payments of $0.01 or more.")
  254.                       sleep(3)
  255.                       term.clear()
  256.                       term.setCursorPos(1,1)
  257.                     else
  258.                       term.clear()
  259.                       term.setCursorPos(1,1)
  260.                       interMuny = (interMuny-0) - (inp-0)
  261.                       interMunye = (interMunye-0) + (inp-0)
  262.                       iAW = fs.open("acc/"..interAcct..".txt", "w")
  263.                       iAW.writeLine(interName)
  264.                       iAW.writeLine(interPass)
  265.                       iAW.writeLine(interMuny)
  266.                       iAW.close()
  267.                       iAWe = fs.open("acc/"..interAccte..".txt", "w")
  268.                       iAWe.writeLine(interNamee)
  269.                       iAWe.writeLine(interPasse)
  270.                       iAWe.writeLine(interMunye)
  271.                       iAWe.close()
  272.                       print("Transaction complete.")
  273.                       sleep(3)
  274.                       term.clear()
  275.                       term.setCursorPos(1,1)
  276.                     end
  277.                   elseif inp=="b" then
  278.                     term.clear()
  279.                     term.setCursorPos(1,1)
  280.                   else
  281.                     term.clear()
  282.                     term.setCursorPos(1,1)
  283.                     print("That was not an option.")
  284.                     sleep(3)
  285.                     term.clear()
  286.                     term.setCursorPos(1,1)
  287.                   end
  288.                 else
  289.                   term.clear()
  290.                   term.setCursorPos(1,1)
  291.                   print("That internal account does not exist.")
  292.                   sleep(3)
  293.                   term.clear()
  294.                   term.setCursorPos(1,1)
  295.                 end
  296.               else
  297.                 term.clear()
  298.                 term.setCursorPos(1,1)
  299.                 print("Access Denied.")
  300.                 sleep(3)
  301.                 term.clear()
  302.                 term.setCursorPos(1,1)
  303.               end
  304.             else
  305.               term.clear()
  306.               term.setCursorPos(1,1)
  307.               print("That internal account does not exist.")
  308.               sleep(3)
  309.               term.clear()
  310.               term.setCursorPos(1,1)
  311.             end
  312.           elseif inp=="d" then
  313.             term.clear()
  314.             term.setCursorPos(1,1)
  315.             print("What would you like to call this account?")
  316.             write("Account name: ")
  317.             interAcct = read()
  318.             if fs.exists("acc/"..interAcct..".txt")==false then
  319.               h = fs.open("acc/"..interAcct..".txt", "w")
  320.               term.clear()
  321.               term.setCursorPos(1,1)
  322.               write("Enter a password: ")
  323.               interPass = read("*")
  324.               term.clear()
  325.               term.setCursorPos(1,1)
  326.               print("How much money would you like to open this account with?")
  327.               write("$")
  328.               inp = read()
  329.               if inp-0 < 0 or inp-0==0 then
  330.                 term.clear()
  331.                 term.setCursorPos(1,1)
  332.                 print("Accounts can only be opened with $0.01 and over.")
  333.                 sleep(3)
  334.                 term.clear()
  335.                 term.setCursorPos(1,1)
  336.               elseif inp-0 > muny-0 then
  337.                 term.clear()
  338.                 term.setCursorPos(1,1)
  339.                 print("Your account has insufficient funds.")
  340.                 sleep(3)
  341.                 term.clear()
  342.                 term.setCursorPos(1,1)
  343.               else
  344.                 term.clear()
  345.                 term.setCursorPos(1,1)
  346.                 interMuny = (inp-0)
  347.                 muny = (muny-0) - (inp-0)
  348.                 h.writeLine(name)
  349.                 h.writeLine(interPass)
  350.                 h.writeLine(interMuny)
  351.                 h.close()
  352.                 h = fs.open("disk/acc/"..acct..".txt", "w")
  353.                 h.writeLine(name)
  354.                 h.writeLine(pass)
  355.                 h.writeLine(interMuny)
  356.                 print("Internal Account Created.")
  357.                 sleep(3)
  358.                 term.clear()
  359.                 term.setCursorPos(1,1)
  360.               end
  361.             else
  362.               term.clear()
  363.               term.setCursorPos(1,1)
  364.               print("This account already exists.")
  365.               sleep(3)
  366.               term.clear()
  367.               term.setCursorPos(1,1)
  368.             end
  369.           elseif inp=="e" then
  370.             term.clear()
  371.             term.setCursorPos(1,1)
  372.             print("What would you like to call this account?")
  373.             interAcct = read()
  374.             if fs.exists("disk/acc/"..interAcct..".txt")==false then
  375.               term.clear()
  376.               term.setCursorPos(1,1)
  377.               write("Enter a password: ")
  378.               interPass = read("*")
  379.               term.clear()
  380.               term.setCursorPos(1,1)
  381.               print("How much money would you like to open this account with?")
  382.               write("$")
  383.               inp = read()
  384.               if inp-0 < 0 or inp-0 == 0 then
  385.                 term.clear()
  386.                 term.setCursorPos(1,1)
  387.                 print("Accounts can only be opened with $0.01 or more.")
  388.                 sleep(3)
  389.                 term.clear()
  390.                 term.setCursorPos(1,1)
  391.               elseif inp-0 > muny-0 then
  392.                 term.clear()
  393.                 term.setCursorPos(1,1)
  394.                 print("Your account has insufficient funds.")
  395.                 sleep(3)
  396.                 term.clear()
  397.                 term.setCursorPos(1,1)
  398.               else
  399.                 term.clear()
  400.                 term.setCursorPos(1,1)
  401.                 muny = (muny-0) - (inp-0)
  402.                 interMuny = (inp-0)
  403.                 h = fs.open("disk/acc/"..acct..".txt", "w")
  404.                 h.writeLine(name)
  405.                 h.writeLine(pass)
  406.                 h.writeLine(muny)
  407.                 h.close()
  408.                 h = fs.open("disk/acc/"..interAcct..".txt", "w")
  409.                 h.writeLine(name)
  410.                 h.writeLine(interPass)
  411.                 h.writeLine(interMuny)
  412.                 h.close()
  413.                 print("External Account Created.")
  414.                 sleep(3)
  415.                 term.clear()
  416.                 term.setCursorPos(1,1)
  417.               end
  418.             else
  419.               term.clear()
  420.               term.setCursorPos(1,1)
  421.               print("This account already exists.")
  422.               sleep(3)
  423.               term.clear()
  424.               term.setCursorPos(1,1)
  425.             end
  426.           elseif inp=="f" then
  427.             term.clear()
  428.             term.setCursorPos(1,1)
  429.             print("Ejecting Electronic Banking Card.")
  430.             disk.eject("left")
  431.             sleep(3)
  432.             term.clear()
  433.             term.setCursorPos(1,1)
  434.             break
  435.           else
  436.             term.clear()
  437.             term.setCursorPos(1,1)
  438.             print("That was not an option.")
  439.             term.clear()
  440.             term.setCursorPos(1,1)
  441.           end
  442.         end
  443.       else
  444.         term.clear()
  445.         term.setCursorPos(1,1)  
  446.         print("Access Denied.")
  447.         sleep(3)
  448.         term.clear()
  449.         term.setCursorPos(1,1)
  450.       end
  451.     else
  452.       term.clear()
  453.       term.setCursorPos(1,1)
  454.       print("That account does not exist.")
  455.       sleep(3)
  456.       term.clear()
  457.       term.setCursorPos(1,1)
  458.     end
  459.   else
  460.     term.clear()
  461.     term.setCursorPos(1,1)
  462.     print("This is not a banking card.")
  463.     sleep(5)
  464.     term.clear()
  465.     term.setCursorPos(1,1)
  466.   end
  467. else
  468.   sleep(1)
  469. end
  470. end
Add Comment
Please, Sign In to add comment