Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --NEW card reading system.
- --this program asks for the item being bought, then asks for card. once swiped, the script will have the cash transfered to the correct Parties
- local OwnerAccount = nil
- local ItemsSold = {...}
- local ItemCost = {...}
- local reader = peripheral.find("reader")
- start()
- local function start()
- if fs.exists("Config") == false then
- Config("Save")
- else
- Config("Load")
- end
- Menu()
- end
- local function Menu()
- term.clear()
- term.setCursorPos(1,1)
- print("WELCOME!")
- print("Options")
- print("1 - Purchase")
- print("2 - Settings")
- repeat
- local event, key = os.pullEvent("key")
- until event == key
- if key == keys.1 then
- PurchaseManager()
- elseif key == keys.two then
- SettingsMenu()
- end
- end
- local function PurchaseManager()
- term.clear()
- term.setCursorPos(1,1)
- print("Please enter the Number Corsponding to the Item desired. press enter to save")
- print("1= "...ItemsSold[1]...", 2= "...ItemsSold[2]...", 3= "...ItemsSold[3])
- print("4= "...ItemsSold[4]...", 5= "...ItemsSold[5]...", 6= "...ItemsSold[6])
- print("7= "...ItemsSold[7]...", 8= "...ItemsSold[8]...", 9= "...ItemsSold[9])
- local Amount = 0
- local input = read()
- repeat
- local event, key = os.pullEvent("key")
- Amount = Amount + ItemCost[key]
- term.setCursorPos(1,8)
- term.clearLine()
- term.write(input)
- until key == keys.enter
- term.clear()
- term.setCursorPos(1,1)
- print("please Insert Card to continue")
- local event, data = os.pullEvent("mag_swipe")
- local DA = data
- local Key = DA[1]
- local AccountID = DA[2]
- shell.run("BankingAccess_Client",Amount,AccountID,Key,OwnerAccount)
- print("Now Attempting Transfer, once transfer is")
- print("complete, you will be brought back to the menu")
- sleep(10)
- Menu()
- end
- local function SettingsMenu()
- term.clear()
- term.setCursorPos(1,1)
- print("SETTINGS")
- print("Options")
- print("1-Add Item")
- print("2-Remove Item")
- print("3-AccountID")
- print("4-Menu")
- 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.1 then
- Settings_ItemMenu("Add")
- elseif key == keys.2 then
- Settings_ItemMenu("Remove")
- elseif key == keys.3 then
- Settings_Account()
- elseif key == keys.4 then
- Menu()
- end
- end
- local function Settings_ItemMenu(type)
- term.clear()
- term.setCursorPos(1,1)
- print("item menu - "...type)
- print("Please enter Number corsponding to the item")
- print(ItemsSold)
- local event, key = os.pullEvent("key")
- print("now "...type..." Item")
- if type == "Remove" then
- ItemsSold[key] = nil
- print("Item Deleted")
- elseif type == "Add" then
- print("Please now type Name of item, once done press enter")
- local input = read()
- repeat
- local event, key = os.pullEvent("key")
- until key == keys.enter
- ItemsSold[key] = input
- print("Item Added")
- end
- Config("Save")
- sleep(5)
- SettingsMenu()
- end
- local function Settings_Account()
- term.clear()
- term.setCursorPos(1,1)
- print("Account Management")
- print("please enter Account ID")
- print("then press enter to save")
- local input = read()
- repeat
- local event, key = os.pullEvent("key")
- until key == keys.enter
- OwnerAccount = input
- Config("Save")
- print("Saved")
- sleep(5)
- SettingsMenu()
- end
- local function Config(Mode)
- local file = fs.open("Config","a")
- if Mode == "Save" then
- file.clear()
- file.setCursorPos(1,1)
- file.writeLine(OwnerAccount)
- file.writeLine(ItemsSold)
- file.writeLine(ItemCost)
- elseif Mode == "load" then
- OwnerAccount = file.readLine(1)
- ItemsSold = {...file.readLine(2)...}
- ItemCost = {...file.readLine(3)...}
- end
- file.close()
- end
Add Comment
Please, Sign In to add comment