Advertisement
Marlingaming

CC Tweaked Banking Client App - banking_public2

Jan 28th, 2022 (edited)
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.83 KB | None | 0 0
  1. local Username = "guest"
  2. local BankScript = "os/System/Programs/BankingSystem-banking_public2"
  3. local BankFile = "os/System/Files/.Banking"
  4.  
  5. local function Clear()
  6. term.clear()
  7. term.setCursorPos(1,1)
  8. end
  9.  
  10. function CUI(m) --declare function
  11. n=1
  12. local l = #m
  13. while true do
  14. term.setCursorPos(1,5)
  15. for i=1, #m, 1 do --traverse the table of options
  16. if i==n then term.clearLine() print(i, ">",m[i]) else term.clearLine() print(i, "-", m[i]) end --print them
  17. end
  18. a, b= os.pullEvent("key") --wait for keypress
  19. if b==keys.w and n>1 then n=n-1 end
  20. if b==keys.s and n<l then n=n+1 end
  21. if b==keys.enter then break end
  22. end
  23. return n --return the value
  24. end
  25.  
  26. function TransferScreen()
  27. Clear()
  28. print("please choose action")
  29. local options = {"send","exit"}
  30. local n = CUI(options)
  31. if options[n] == "exit" then
  32.     Menu()
  33. elseif options[n] == "send" then
  34.     Clear()
  35.     print("enter Amount")
  36.     local input
  37.     while true do
  38.         local event = {os.pullEvent("key")}
  39.         if event[2] == keys.enter then break end
  40.         input = read()
  41.     end
  42.     local Amount = input
  43.     Clear()
  44.     print("enter Target")
  45.     while true do
  46.         local event = {os.pullEvent("key")}
  47.         if event[2] == keys.enter then break end
  48.         input = read()
  49.     end
  50.     shell.run(BankScript,"Transfer", Amount,input)
  51.     os.sleep(2)
  52.     TransferScreen()
  53. end
  54. end
  55.  
  56. function Menu()
  57. Clear()
  58. print("hello ",Username)
  59. local options = {"Details","Transfer","exit"}
  60. local n = CUI(options)
  61. if options[n] == "exit" then
  62.  
  63. elseif options[n] == "Transfer" then
  64.     TransferScreen()
  65. elseif options[n] == "Details" then
  66.     Clear()
  67.     print("press enter to exit")
  68.     shell.run(BankScript,"details")
  69.     repeat
  70.         local event, key = os.pullEvent("key")
  71.     until key == keys.enter
  72.     Menu()
  73. end
  74. end
  75.  
  76. function FirstStart()
  77. Clear()
  78. print("hello! And welcome to Imperial Banking Net")
  79. local options = {"Login","create account","exit"}
  80. local n = CUI(options)
  81. if options[n] == "Login" then
  82.     LoginScreen()
  83. elseif options[n] == "create account" then
  84.     CreateAccount()
  85. elseif options[n] == "exit" then
  86.  
  87. end
  88. end
  89.  
  90. function LoginScreen()
  91. Clear()
  92. print("please enter Username")
  93. local input
  94. while true do
  95.     local event = {os.pullEvent("key")}
  96.     if event[2] == keys.enter then break end
  97.     input = read()
  98. end
  99. shell.run(BankScript,"Login",input)
  100. if fs.exists(BankFile) then
  101.     Menu()
  102. else
  103.     FirstStart()
  104. end
  105. end
  106.  
  107. function CreateAccount()
  108. Clear()
  109. print("please enter username")
  110. local input
  111. while true do
  112.     local event = {os.pullEvent("key")}
  113.     if event[2] == keys.enter then break end
  114.     input = read()
  115. end
  116. print("contacting servers")
  117. shell.run(BankScript,"CreateAccount")
  118. if fs.exists(BankFile) then
  119.     Menu()
  120. else
  121.     FirstStart()
  122. end
  123. end
  124.  
  125. if fs.exists(BankFile) then
  126.     Menu()
  127. else
  128.     FirstStart()
  129. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement