Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.pullEvent = os.pullEventRaw
- settings.load(".settings")
- local ItemNames = {}
- local ItemTags = {}
- local ItemPrices = {}
- local ItemAmount = {}
- local ItemSellAmount = {}
- local ItemInStock = {}
- local Balance = 0
- local BankScript = "Kiosk/KioskBankSystem-banking_public2"
- --DO NOT MESS WITH COIN NAMES AND VALUES
- local CoinNames = {"Neb","Thero","Gold Coin"}
- local CoinValues = {1,32,128}
- --wither to use data off of a file or set program values
- local FileUse = true
- local CardAccept = false
- local Storage = peripherals.wrap("minecraft:chest_0")
- local Deposit = peripherals.wrap("minecraft:chest_1")
- local function Clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- local function Setup()
- Clear()
- print("Files not found, please create 'Shop' file in 'Kiosk' file")
- print("should be named this 'Kiosk/Shop'")
- os.sleep(7)
- exit
- end
- function Purchase_Card(item)
- Clear()
- print("Please Swipe Card")
- local Reader = peripherals.find("reader")
- local event, a, b, c = os.pullEvent("mag_swipe)
- shell.run(BankScript,"transfer",ItemPrices[item],c)
- settings.load(".settings")
- if settings.get("Pass") == true then
- print("Transaction Accepted")
- Dispense(item,ItemSellAmount[item])
- os.sleep(3)
- else
- print("Transaction Rejected")
- os.sleep(3)
- end
- end
- function Purchase_Manual(item,Set)
- Clear()
- print("please place current change into chest, then press enter")
- print("Costs ",ItemPrices[item])
- repeat
- local event, key = os.pullEvent("key")
- until key == keys.enter
- term.setCursorPos(1,7)
- local PaidAmount = 0
- if Set ~= nil then
- PaidAmount = Set
- end
- for slot, item in pairs(Deposit.list()) do
- term.clearLine()
- term.write(PaidAmount)
- if PaidAmount < ItemPrices[item] then
- if item.name == CoinNames[1] then
- PaidAmount = PaidAmount + (CoinValues[1] * item.amount)
- Deposit.pushItems(peripheral.getName(Storage),slot)
- elseif item.name == CoinNames[2] then
- PaidAmount = PaidAmount + CoinValues[2] * item.amount)
- Deposit.pushItems(peripheral.getName(Storage),slot)
- elseif item.name == CoinNames[3] then
- PaidAmount = PaidAmount + CoinValues[3] * item.amount)
- Deposit.pushItems(peripheral.getName(Storage),slot)
- end
- end
- end
- if PaidAmount >= ItemPrices[item] then
- print("Sufficent Payment")
- Dispense(item,ItemSellAmount[item])
- else
- print("Insufficent Payment")
- Purchase_Manual(item,PaidAmount)
- end
- end
- function Dispense(item,x)
- local DisAmount = 0
- for slot, item in pairs(Storage.list()) do
- if DisAmount < ItemSellAmount[item] then
- if item.name == ItemNames[item] then
- DisAmount = DisAmount + item.count
- Storage.pushItems(peripheral.getName(Deposit),slot,(ItemSellAmount[item] - DisAmount))
- end
- end
- end
- end
- function TransactionMenu(method)
- Clear()
- if method == "deposit" then
- print("please place Currency in chest below, then press enter")
- repeat
- local event, key = os.pullEvent("key")
- until key == keys.enter
- PullCash()
- elseif method == "withdraw" then
- print("please type amount then press enter")
- local input
- if Balance - input >= 0 then
- PushCash(input)
- else
- print("insignificant funds")
- os.sleep(2)
- end
- end
- end
- function ATMMenu()
- Clear()
- if fs.exists("User") then fs.delete("User") end
- shell.run(BankScript,"Details")
- local options = {"withdraw","deposit","logout"}
- print("hello, ",settings.get("User"))
- print(Balance)
- local n = CUI(options)
- if options[n] == "logout" then
- settings.set("User","n")
- settings.save(".settings")
- else
- TransactionMenu(options[n])
- ATMMenu()
- end
- end
- function ATMLogin()
- settings.set("User","n")
- settings.save(".settings")
- settings.load(".settings")
- Clear()
- print("===Login=ATM===")
- print ("if you have a account, please swipe card now")
- print("if you donβt have a account, please contact closest bank member for help")
- local a, b, c, d
- repeat
- a, b, c, d = os.pullEvent("mag_swipe")
- until a == "mag_swipe"
- shell.run(BankScript,"Login",d)
- if settings.get("User") ~= "n" then
- ATMMenu()
- else
- print("account not found")
- os.sleep(2)
- end
- ATMLogin()
- end
- function GetStock()
- for slot, item in pairs(Storage.list()) do
- for I = 1, #ItemNames do
- if item.name == ItemNames[I] then
- if ItemAmount[I] == nil then
- ItemAmount[I] = item.count
- else
- ItemAmount[I] = ItemAmount[I] + item.count
- end
- end
- end
- end
- for i = 1, #ItemNames do
- if ItemAmount[i] >= ItemSellAmount[i] then
- ItemInStock[i] = true
- else
- ItemInStock[i] = false
- end
- end
- local SellItems = {}
- for A = 1, #ItemNames do
- if ItemInStock[A] == true then
- SellItems[#SellItems + 1] = A
- end
- end
- return(SellItems)
- end
- ATMLogin()
Add Comment
Please, Sign In to add comment