Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --this script deals with AccountManagement
- version = "1.0.0"
- local tArg = {..}--Account
- local Account = tArg[0]
- local CurrencyName = {"$1","$5","$10","$20","$50"}
- local CurrencyValue = {1,5,10,20,50}
- local Balance = 0
- local CreditCardUse = false
- local function Clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- local function GetBalance()
- local file = fs.open(Account,"r")
- file.nextLine()
- Balance = file.readLine()
- file.close()
- end
- local function MainMenu()
- Clear()
- GetBalance()
- print("Banking Terminal--- Version = "..version)
- print("Welcome, "..Account)
- print("Balance = $"..Balance)
- print("OPTIONS")
- print("1 - Deposit")
- print("2 - Withdraw")
- print("3 - Logout")
- repeat
- local event, key = os.pullEvent("key")
- until key == keys.one or key == keys.two or key == keys.three
- if key == keys.one then
- DepositMenu()
- elseif key == keys.two then
- WithdrawMenu()
- elseif key == keys.three then
- Logout()
- end
- end
- local function DepositMenu()
- Clear()
- print("DEPOSIT")
- print("place Currency in Chest to your left, then press Enter")
- repeat
- local event, key = os.pullEvent("key")
- until key == keys.enter
- local DepositChest = peripheral.find("minecraft:chest_0")
- local StoreChest1 = peripheral.find("minecraft:chest_1")
- local StoreChest2 = peripheral.find("minecraft:chest_2")
- local StoreChest3 = peripheral.find("minecraft:chest_3")
- local StoreChest4 = peripheral.find("minecraft:chest_4")
- local StoreChest5 = peripheral.find("minecraft:chest_5")
- local Amount = 0
- for i = 0, #DepositChest.items do
- if DepositChest.itemSlot[i].displayName == CurrencyName[0] then
- Amount = Amount + CurrencyValue[0]
- DepositChest.pushItems(i,peripheral.find(StoreChest1))
- elseif DepositChest.itemSlot[i].displayName == CurrencyName[1] then
- Amount = Amount + CurrencyValue[1]
- DepositChest.pushItems(i,peripheral.find(StoreChest2))
- elseif DepositChest.itemSlot[i].displayName == CurrencyName[2] then
- Amount = Amount + CurrencyValue[2]
- DepositChest.pushItems(i,peripheral.find(StoreChest3))
- elseif DepositChest.itemSlot[i].displayName == CurrencyName[3] then
- Amount = Amount + CurrencyValue[3]
- DepositChest.pushItems(i,peripheral.find(StoreChest4))
- elseif DepositChest.itemSlot[i].displayName == CurrencyName[4] then
- Amount = Amount + CurrencyValue[4]
- DepositChest.pushItems(i,peripheral.find(StoreChest5))
- end
- end
- print("Stored Currency, Updating Account")
- shell.run("TransferManager",Amount,Account,"Local",0)
- print("Transfer Successful")
- MainMenu()
- end
- local function WithdrawMenu()
- Clear()
- print("WITHDRAW")
- print("Balance = $"..Balance)
- print("Please enter desired Bills, then press enter")
- print("1 - "..CurrencyName[0])
- print("2 - "..CurrencyName[1])
- print("3 - "..CurrencyName[2])
- print("4 - "..CurrencyName[3])
- print("5 - "..CurrencyName[4])
- local Cur1 = 0
- local Cur2 = 0
- local Cur3 = 0
- local Cur4 = 0
- local Cur5 = 0
- local Amount = 0
- repeat
- local event,key = os.pullEvent("key")
- if key == keys.one then
- Cur1 = Cur1+1
- Amount = Amount + CurrencyValue[0]
- elseif key == keys.two then
- Cur2 = Cur2+1
- Amount = Amount + CurrencyValue[1]
- elseif key == keys.three then
- Cur3 = Cur3+1
- Amount = Amount + CurrencyValue[2]
- elseif key == keys.four then
- Cur4 = Cur4+1
- Amount = Amount + CurrencyValue[3]
- elseif key == keys.five then
- Cur5 = Cur5+1
- Amount = Amount + CurrencyValue[4]
- end
- until key == keys.enter
- if Amount < Balance then
- print("Transfer Accepted")
- shell.run("TransferManager",(Amount*-1),Account,"Local",0)
- if CreditCardUse == false then
- local DepositChest = peripheral.find("minecraft:chest_0")
- local StoreChest1 = peripheral.find("minecraft:chest_1")
- local StoreChest2 = peripheral.find("minecraft:chest_2")
- local StoreChest3 = peripheral.find("minecraft:chest_3")
- local StoreChest4 = peripheral.find("minecraft:chest_4")
- local StoreChest5 = peripheral.find("minecraft:chest_5")
- StoreChest1.pushItems(DepositChest,0,Cur1)
- StoreChest2.pushItems(DepositChest,0,Cur2)
- StoreChest3.pushItems(DepositChest,0,Cur3)
- StoreChest4.pushItems(DepositChest,0,Cur4)
- StoreChest5.pushItems(DepositChest,0,Cur5)
- elseif CreditCardUse == true then
- shell.run("CreditCardManager",Amount)
- end
- os.sleep(3)
- MainMenu()
- else
- print("Insignificant Funds")
- os.sleep(3)
- MainMenu()
- end
- end
- local function Logout()
- shell.run("LoginManager")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement