Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --this script allows easy exchange of coins for Credits
- local Coins = {{"Neb",1,"createdeco:copper_coin"},{"Iron Coin",32,"createdeco:iron_coin"},{"Gold Coin",128,"createdeco:gold_coin"}}
- local ATMVersion = "1.0.0"
- local User = "guest"
- local BankingFormat = "banking_public1"
- local Data
- local function Clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- local function Count()
- local chest = peripheral.find("chest")
- local Currency = 0
- local slots = {chest.list()}
- for i = 1, #slots do
- local item = chest.getItemDetail(i)
- if item.displayName == Coins[1][1] and item.name == Coins[1][3] then
- Currency = Currency + (Coins[1][2] * item.count)
- elseif item.displayName == Coins[2][1] and item.name == Coins[2][3] then
- Currency = Currency + (Coins[2][2] * item.count)
- elseif item.displayName == Coins[3][1] and item.name == Coins[3][3] then
- Currency = Currency + (Coins[3][2] * item.count)
- end
- end
- return(currency)
- end
- local function MoveCoinsIn()
- local chest = peripheral.find("chest_1")
- local store = peripheral.find("chest_2")
- local slots = {chest.list()}
- for i = 1, #slots do
- local item = chest.getItemDetail(i)
- if item.displayName == Coins[1][1] and item.name == Coins[1][3] then
- chest.pushItems(store,i)
- elseif item.displayName == Coins[2][1] and item.name == Coins[2][3] then
- chest.pushItems(store,i)
- elseif item.displayName == Coins[3][1] and item.name == Coins[3][3] then
- chest.pushItems(store,i)
- end
- end
- end
- local function DrawMenu()
- Clear()
- print("Banking Terminal")
- print("Hello, "..User)
- print("====OPTIONS====")
- print("1 - withdraw - WIP")
- print("2 - deposit")
- print("3 - logout")
- end
- local function DrawLogin()
- term.setBackgroundColor(colors.cyan)
- Clear()
- print("BANKING TERMINAL - "..BankingFormat)
- print("version = "..ATMVersion)
- print("LOGIN")
- print("please swipe card to log in")
- end
- local function DrawTransferMenu(mode)
- Clear()
- if mode == "deposit" then
- print("Place Coins in Chest")
- elseif mode == "widthdraw" then
- print("please enter desired amount")
- end
- end
- local function TransferMenu(V)
- local Amount
- if V == 1 then
- DrawTransferMenu("deposit")
- repeat
- local event, key = os.pullEvent("key")
- until key == keys.enter
- Amount = Counter()
- MoveCoinsIn()
- local Request = {BankingFormat,Amount,"ATM","deposit","deposit"}
- rednet.send(Data[2],Request,Data[3])
- MainMenu()
- else
- DrawTransferMenu("withdraw")
- end
- end
- local function MainMenu()
- DrawMenu()
- local event, key
- repeat
- event, key = os.pullEvent("key")
- until key == keys.one or key == keys.two or key == keys.three
- if key == keys.one then
- TransferMenu(-1)
- elseif key == keys.two then
- TransferMenu(1)
- elseif key == keys.three then
- os.reboot()
- end
- end
- local function LoginMenu()
- DrawLogin()
- while true do
- local a, b, c = os.pullEvent("mag_swipe")
- Data = {c}
- if Data[1] = BankingFormat then break end
- end
- User = Data[2]
- MainMenu()
- end
- LoginMenu()
Add Comment
Please, Sign In to add comment