Marlingaming

CC Tweaked National Banking - Standardized ATM banking_public1

Jan 20th, 2022 (edited)
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. --this script allows easy exchange of coins for Credits
  2. local Coins = {{"Neb",1,"createdeco:copper_coin"},{"Iron Coin",32,"createdeco:iron_coin"},{"Gold Coin",128,"createdeco:gold_coin"}}
  3. local ATMVersion = "1.0.0"
  4. local User = "guest"
  5. local BankingFormat = "banking_public1"
  6. local Data
  7.  
  8. local function Clear()
  9. term.clear()
  10. term.setCursorPos(1,1)
  11. end
  12.  
  13. local function Count()
  14. local chest = peripheral.find("chest")
  15. local Currency = 0
  16. local slots = {chest.list()}
  17. for i = 1, #slots do
  18. local item = chest.getItemDetail(i)
  19. if item.displayName == Coins[1][1] and item.name == Coins[1][3] then
  20. Currency = Currency + (Coins[1][2] * item.count)
  21. elseif item.displayName == Coins[2][1] and item.name == Coins[2][3] then
  22. Currency = Currency + (Coins[2][2] * item.count)
  23. elseif item.displayName == Coins[3][1] and item.name == Coins[3][3] then
  24. Currency = Currency + (Coins[3][2] * item.count)
  25. end
  26. end
  27. return(currency)
  28. end
  29.  
  30. local function MoveCoinsIn()
  31. local chest = peripheral.find("chest_1")
  32. local store = peripheral.find("chest_2")
  33. local slots = {chest.list()}
  34. for i = 1, #slots do
  35. local item = chest.getItemDetail(i)
  36. if item.displayName == Coins[1][1] and item.name == Coins[1][3] then
  37. chest.pushItems(store,i)
  38. elseif item.displayName == Coins[2][1] and item.name == Coins[2][3] then
  39. chest.pushItems(store,i)
  40. elseif item.displayName == Coins[3][1] and item.name == Coins[3][3] then
  41. chest.pushItems(store,i)
  42. end
  43. end
  44. end
  45.  
  46. local function DrawMenu()
  47. Clear()
  48. print("Banking Terminal")
  49. print("Hello, "..User)
  50. print("====OPTIONS====")
  51. print("1 - withdraw - WIP")
  52. print("2 - deposit")
  53. print("3 - logout")
  54. end
  55.  
  56. local function DrawLogin()
  57. term.setBackgroundColor(colors.cyan)
  58. Clear()
  59. print("BANKING TERMINAL - "..BankingFormat)
  60. print("version = "..ATMVersion)
  61. print("LOGIN")
  62. print("please swipe card to log in")
  63. end
  64.  
  65. local function DrawTransferMenu(mode)
  66. Clear()
  67. if mode == "deposit" then
  68. print("Place Coins in Chest")
  69. elseif mode == "widthdraw" then
  70. print("please enter desired amount")
  71. end
  72. end
  73.  
  74. local function TransferMenu(V)
  75. local Amount
  76. if V == 1 then
  77. DrawTransferMenu("deposit")
  78. repeat
  79. local event, key = os.pullEvent("key")
  80. until key == keys.enter
  81. Amount = Counter()
  82. MoveCoinsIn()
  83. local Request = {BankingFormat,Amount,"ATM","deposit","deposit"}
  84. rednet.send(Data[2],Request,Data[3])
  85. MainMenu()
  86. else
  87. DrawTransferMenu("withdraw")
  88. end
  89. end
  90.  
  91. local function MainMenu()
  92. DrawMenu()
  93. local event, key
  94. repeat
  95. event, key = os.pullEvent("key")
  96. until key == keys.one or key == keys.two or key == keys.three
  97. if key == keys.one then
  98. TransferMenu(-1)
  99. elseif key == keys.two then
  100. TransferMenu(1)
  101. elseif key == keys.three then
  102. os.reboot()
  103. end
  104. end
  105.  
  106. local function LoginMenu()
  107. DrawLogin()
  108. while true do
  109. local a, b, c = os.pullEvent("mag_swipe")
  110. Data = {c}
  111. if Data[1] = BankingFormat then break end
  112. end
  113. User = Data[2]
  114. MainMenu()
  115. end
  116.  
  117. LoginMenu()
  118.  
Add Comment
Please, Sign In to add comment