Advertisement
Marlingaming

Banking Terminal Main Program V1

Dec 6th, 2021 (edited)
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 KB | None | 0 0
  1. --this script deals with AccountManagement
  2. version = "1.0.0"
  3. local tArg = {..}--Account
  4. local Account = tArg[0]
  5. local CurrencyName = {"$1","$5","$10","$20","$50"}
  6. local CurrencyValue = {1,5,10,20,50}
  7. local Balance = 0
  8. local CreditCardUse = false
  9.  
  10. local function Clear()
  11. term.clear()
  12. term.setCursorPos(1,1)
  13. end
  14.  
  15. local function GetBalance()
  16. local file = fs.open(Account,"r")
  17. file.nextLine()
  18. Balance = file.readLine()
  19. file.close()
  20. end
  21.  
  22. local function MainMenu()
  23. Clear()
  24. GetBalance()
  25. print("Banking Terminal--- Version = "..version)
  26. print("Welcome, "..Account)
  27. print("Balance = $"..Balance)
  28. print("OPTIONS")
  29. print("1 - Deposit")
  30. print("2 - Withdraw")
  31. print("3 - Logout")
  32. repeat
  33. local event, key = os.pullEvent("key")
  34. until key == keys.one or key == keys.two or key == keys.three
  35. if key == keys.one then
  36. DepositMenu()
  37. elseif key == keys.two then
  38. WithdrawMenu()
  39. elseif key == keys.three then
  40. Logout()
  41. end
  42. end
  43.  
  44. local function DepositMenu()
  45. Clear()
  46. print("DEPOSIT")
  47. print("place Currency in Chest to your left, then press Enter")
  48. repeat
  49. local event, key = os.pullEvent("key")
  50. until key == keys.enter
  51. local DepositChest = peripheral.find("minecraft:chest_0")
  52. local StoreChest1 = peripheral.find("minecraft:chest_1")
  53. local StoreChest2 = peripheral.find("minecraft:chest_2")
  54. local StoreChest3 = peripheral.find("minecraft:chest_3")
  55. local StoreChest4 = peripheral.find("minecraft:chest_4")
  56. local StoreChest5 = peripheral.find("minecraft:chest_5")
  57. local Amount = 0
  58. for i = 0, #DepositChest.items do
  59. if DepositChest.itemSlot[i].displayName == CurrencyName[0] then
  60. Amount = Amount + CurrencyValue[0]
  61. DepositChest.pushItems(i,peripheral.find(StoreChest1))
  62. elseif DepositChest.itemSlot[i].displayName == CurrencyName[1] then
  63. Amount = Amount + CurrencyValue[1]
  64. DepositChest.pushItems(i,peripheral.find(StoreChest2))
  65. elseif DepositChest.itemSlot[i].displayName == CurrencyName[2] then
  66. Amount = Amount + CurrencyValue[2]
  67. DepositChest.pushItems(i,peripheral.find(StoreChest3))
  68. elseif DepositChest.itemSlot[i].displayName == CurrencyName[3] then
  69. Amount = Amount + CurrencyValue[3]
  70. DepositChest.pushItems(i,peripheral.find(StoreChest4))
  71. elseif DepositChest.itemSlot[i].displayName == CurrencyName[4] then
  72. Amount = Amount + CurrencyValue[4]
  73. DepositChest.pushItems(i,peripheral.find(StoreChest5))
  74. end
  75. end
  76. print("Stored Currency, Updating Account")
  77. shell.run("TransferManager",Amount,Account,"Local",0)
  78. print("Transfer Successful")
  79. MainMenu()
  80. end
  81.  
  82. local function WithdrawMenu()
  83. Clear()
  84. print("WITHDRAW")
  85. print("Balance = $"..Balance)
  86. print("Please enter desired Bills, then press enter")
  87. print("1 - "..CurrencyName[0])
  88. print("2 - "..CurrencyName[1])
  89. print("3 - "..CurrencyName[2])
  90. print("4 - "..CurrencyName[3])
  91. print("5 - "..CurrencyName[4])
  92. local Cur1 = 0
  93. local Cur2 = 0
  94. local Cur3 = 0
  95. local Cur4 = 0
  96. local Cur5 = 0
  97. local Amount = 0
  98. repeat
  99. local event,key = os.pullEvent("key")
  100. if key == keys.one then
  101. Cur1 = Cur1+1
  102. Amount = Amount + CurrencyValue[0]
  103. elseif key == keys.two then
  104. Cur2 = Cur2+1
  105. Amount = Amount + CurrencyValue[1]
  106. elseif key == keys.three then
  107. Cur3 = Cur3+1
  108. Amount = Amount + CurrencyValue[2]
  109. elseif key == keys.four then
  110. Cur4 = Cur4+1
  111. Amount = Amount + CurrencyValue[3]
  112. elseif key == keys.five then
  113. Cur5 = Cur5+1
  114. Amount = Amount + CurrencyValue[4]
  115. end
  116. until key == keys.enter
  117. if Amount < Balance then
  118. print("Transfer Accepted")
  119. shell.run("TransferManager",(Amount*-1),Account,"Local",0)
  120. if CreditCardUse == false then
  121. local DepositChest = peripheral.find("minecraft:chest_0")
  122. local StoreChest1 = peripheral.find("minecraft:chest_1")
  123. local StoreChest2 = peripheral.find("minecraft:chest_2")
  124. local StoreChest3 = peripheral.find("minecraft:chest_3")
  125. local StoreChest4 = peripheral.find("minecraft:chest_4")
  126. local StoreChest5 = peripheral.find("minecraft:chest_5")
  127. StoreChest1.pushItems(DepositChest,0,Cur1)
  128. StoreChest2.pushItems(DepositChest,0,Cur2)
  129. StoreChest3.pushItems(DepositChest,0,Cur3)
  130. StoreChest4.pushItems(DepositChest,0,Cur4)
  131. StoreChest5.pushItems(DepositChest,0,Cur5)
  132. elseif CreditCardUse == true then
  133. shell.run("CreditCardManager",Amount)
  134. end
  135. os.sleep(3)
  136. MainMenu()
  137. else
  138. print("Insignificant Funds")
  139. os.sleep(3)
  140. MainMenu()
  141. end
  142. end
  143.  
  144. local function Logout()
  145. shell.run("LoginManager")
  146. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement