Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --this script acts as an enclosed Local ATM, meaning all accounts on it cant be transfered to other computers, and cant use rednet, instead the player can deposit and withdraw acceptable currencies
- version = "1.4.5"
- Version = "1.4.0"
- local Ver = "1.4.0"
- local Terminal State = false
- local TerminalAdminCode = 0000
- local SelectedAccount = 'n'
- local AccountBalance = 0
- local AcceptableItems = {false,false,false,false,false} --Iron,Gold,Emeralds,Diamonds
- local ItemValues = {1,2,20,25,0}
- local CurrencyName = {"$1","$5","$20"}
- local CurrencyValue = {1,5,20}
- local StorageChestID = {"minecraft:chest_1", "minecraft:chest_2", "minecraft:chest_3"}
- local DepositChestID = "minecraft:chest_0"
- local Username = "guest"
- local Password = "guest"
- local function LoginMenu()
- term.clear()
- term.setCursorPos(1,1)
- print("-----Logint----")
- print("Username")
- term.setCursorPos(5,3)
- repeat
- local event, key = os.pullEvent("key")
- local User = read()
- until key == keys.enter
- Username = User
- term.setCursorPos(1,4)
- print("Password")
- term.setCursorPos(5,5)
- repeat
- local event, key = os.pullEvent("key")
- local Pass = read()
- until key == keys.enter
- Password = Pass
- if fs.exists(Username) == true then
- local file = fs.open(Username,"r")
- if file.readLine() == Password then
- SelectedAccount = Username
- AccountBalance = file.readLine()
- file.close()
- AccountManagement()
- else
- os.sleep(2)
- os.reboot()
- end
- else
- os.sleep(2)
- os.reboot()
- end
- end
- local function SignupMenu()
- term.clear()
- term.setCursorPos(1,1)
- print("-----Create Account----")
- print("Username")
- term.setCursorPos(5,3)
- repeat
- local event, key = os.pullEvent("key")
- local User = read()
- until key == keys.enter
- Username = User
- term.setCursorPos(1,4)
- print("Password")
- term.setCursorPos(5,5)
- repeat
- local event, key = os.pullEvent("key")
- local Pass = read()
- until key == keys.enter
- Password = Pass
- term.clear()
- term.setCursorPos(1,1)
- print("Creating account....")
- sleep(1)
- local file = fs.open(Username,"w")
- file.writeLine(Password)
- file.writeLine(0)
- file.close()
- print("Rebooting, you can login after the restart")
- os.sleep(2)
- os.reboot()
- end
- local function AdminLogin()
- print("Currently Unavaliable")
- os.sleep(5)
- os.reboot()
- end
- local function AccountManagement()
- Clear()
- print("-----"..SelectedAccount.."----")
- print("Balance = $"..AccountBalance)
- print("--Options--")
- print("1 - Deposit")
- print("2 - Withdraw")
- print("3 - WIP Checks Menu")
- print("4 - nil")
- print("5 - nil")
- print("6 - Logout")
- repeat
- local event, key = os.pullEvent("key")
- until key == keys.one or key == keys.two or key == keys.three or key == keys.four or key == keys.five or key == keys.six
- local event, key = os.pullEvent("key")
- if key == keys.one then
- DepositMenu()
- elseif key == keys.two then
- WithdrawMenu()
- elseif key == keys.three then
- ChecksMenu()
- elseif key == keys.four then
- elseif key == keys.five then
- elseif key == keys.six then
- os.reboot()
- end
- end
- local function ChecksMenu()
- Clear()
- print("- -WIP- - -Checks Menu- - -")
- print("this is a WIP feature")
- print("options")
- print("1 - Print Check")
- print("2 - Redeem Check")
- print("3 - Uncashed Checks")
- print("4 - return")
- repeat
- local event, key = os.pullEvent("key")
- until key == keys.one or key == keys.two or key == keys.three or key == keys.four
- if key == keys.one then
- Checks_PrintMenu()
- elseif key == keys.two then
- Checks_Claim()
- elseif key == keys.three then
- DisplayUnclaimedChecks()
- elseif key == keys.four then
- AccountManagement()
- end
- end
- local function Checks_PrintMenu()
- Clear()
- print("Please Enter Desired Amount, then press enter")
- repeat
- local event, key = os.pullEvent("key")
- local input = read()
- until key == keys.enter
- print(input)
- print("Checking Balance")
- if AccountBalance >= input then
- print("Significant Funds")
- print("Printing Check")
- local CheckID = #fs.list("Checks") + 1
- local check = fs.open("Checks/Check_"..CheckID,"w")
- check.writeLine(SelectedAccount)
- check.writeLine(input)
- check.close()
- print(CheckID)
- os.sleep(5)
- ChecksMenu()
- else
- print("Insignificant Funds")
- os.sleep(2)
- ChecksMenu()
- end
- end
- local function Checks_Claim()
- Clear()
- print("please Enter Check ID, then press Enter")
- local input = read()
- Repeat
- local event, key = os.pullEvent("key")
- until key == keys.enter
- print("checking files")
- if fs.exists("Check_"..input) == true then
- print("Transfering Credit")
- local TargetAccount = ‘guest’
- local Amount = 0
- local check = fs.open("Check_"..input,"r")
- TargetAccount = check.readLine()
- Amount = check.readLine()
- print(TargetAccount)
- print("$"..Amount)
- AccountBalance = AccountBalance + Amount
- UpdateAccount()
- ChargeAccount(TargetAccount,Amount)
- print("Completed")
- os.sleep(4)
- ChecksMenu()
- else
- print("Check doesn’t Exist")
- os.sleep(4)
- ChecksMenu()
- end
- end
- local function DisplayUnclaimedChecks()
- ChecksMenu()
- end
- local function ChargeAccount(Account, Amount)
- local file = fs.open(Account,"w")
- file.nextLine()
- local Balance = file.readLine() - Amount
- file.clearLine()
- file.writeLine(Balance)
- file.close()
- end
- local function DepositMenu()
- term.clear()
- term.setCursorPos(2,5)
- print("DEPOSIT MENU")
- print("Press t once your desired items are in the container to YOUR left of the Terminal")
- print("or press x to exit")
- repeat
- local event, key = os.pullEvent("key")
- until key == keys.t or key == keys.x
- if key == keys.t then
- local Deposit = peripherals.find(DepositChestID)
- local item = Deposit.getItemDetails(1)
- if item.displayName == CurrencyName[0] then
- Deposit.pushItems( peripheral.find(StorageChestID[0]), 1)
- AccountBalance = AccountBalance + CurrencyValue[0]
- elseif item.displayName == CurrencyName[1] then
- Deposit.pushItems( peripheral.find( StorageChestID[1]), 1)
- AccountBalance = AccountBalance + CurrencyValue[1]
- elseif item.displayName == CurrencyName[2] then
- Deposit.pushItems( peripheral.find( StorageChestID[2]), 1)
- AccountBalance = AccountBalance + CurrencyValue[2]
- end
- elseif key == keys.x then
- os.sleep(1)
- UpdateAccount()
- AccountManagement()
- end
- end
- local function WithdrawMenu()
- term.clear()
- term.setCursorPos(2,5)
- print("Withdraw MENU")
- print("Please Press Keys Relating to your request, then Press t")
- print(" 1 - "..CurrencyName[0])
- print(" 2 - "..CurrencyName[1])
- print(" 3 - "..CurrencyName[2])
- local RequestedItems = {0,0,0}
- local RequestedValue = 0
- repeat
- local event, key = os.pullEvent("key")
- term.setCursorPos(3,6)
- term.clearLine()
- term.write("$"..RequestedAmount)
- if key == keys.one then
- RequestedValue = RequestedValue + CurrencyValue[0]
- RequestedItems[0] = RequestedItems[0] + 1
- elseif key == keys.two then
- RequestedValue = RequestedValue + CurrencyValue[1]
- RequestedItems[1] = RequestedItems[1] + 1
- elseif key == keys.three then
- RequestedValue = RequestedValue + CurrencyValue[2]
- RequestedItems[2] = RequestedItems[2] + 1
- end
- until key == keys.t
- print("Processing Request")
- if RequestedValue <= AccountBalance then
- local Deposit = peripheral.find(DepositChestID)
- print("Request Accepted, now Dispensing")
- for i = 0, #RequestedItems do
- for i1 = 0, #RequestedItems[i] do
- Deposit.pullItem( peripheral.find( StorageChestID[I]),1,[0])
- end
- end
- else
- print("Request Declined")
- end
- os.sleep(2)
- AccountManagement()
- end
- local function UpdateAccount()
- local file = fs.open(SelectedAccount,"w")
- file.nextLine()
- file.clearLine()
- file.writeLine(AccountBalance)
- file.close()
- end
- local function Clear()
- term.clear()
- term.setCursorPos()
- end
- Clear()
- if fs.exists("InstalledFile") == true then
- else
- local file = fs.open("InstalledFile","w")
- file.writeLine("Ready")
- file.writeLine("Installed")
- file.close()
- shell.run("pastebin","get","2KmEkzCF","startup")
- shell.run("pastebin","get","Fpt9sZvz","Updater")
- os.sleep(3)
- os.reboot()
- end
- print("----------Banking Termainal---"..Ver)
- print("Options")
- print("1 - Login")
- print("2 - Create Account")
- print("3 - Admin Login")
- print("4 - Reboot")
- repeat
- local event, key = os.pullEvent("key")
- until key == keys.one or key == keys.two or key == keys.three or key == keys.four
- if key == keys.one then
- LoginMenu()
- elseif key == keys.two then
- SignupMenu()
- elseif key == keys.three then
- AdminLogin()
- elseif key == keys.four then
- os.reboot()
- end
Add Comment
Please, Sign In to add comment