Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Edit This\/
- local Items = {} --item tag, display name, {amount per sale, cost, max sale},available
- local BankNet_En = false
- local BankKey = 0001
- local ShopFile = "Products.txt"
- --DONT TOUCH
- local Payment = {{"currency:dollar_bill",1},{"currency:ten_dollar_bill",10},{"currency:twenty_dollar_bill",20},{"currency:fifty_dollar_bill",50},{"currency:hundred_dollar_bill",100}}
- local Version = "1.2.0"
- local ClientBankKey
- local w, h = term.getSize()
- --Change to sides of computer for chests
- local PayChest = peripheral.wrap("top")
- local StoreChest = peripheral.wrap("bottom")
- --Your Name
- local Owner = "Marlin"
- --Company
- local Company = "WST"
- local Label = "Example"
- --DONT TOUCH ANYTHING BEYOND THIS
- local function start()
- for i = 1, #Items do
- local Amount = 0
- for slot, item in pairs(StoreChest.list()) do
- if item.name == Items[i][1] then Amount = Amount + item.count end
- end
- if Amount >= Items[i][3] then Storage[i] = true else Storage[i] = false end
- end
- if Receipt.CheckPrinter() == false then error("printer error") end
- Menu()
- Options()
- end
- local function CurrencyCheck(name)
- local Worth = 0
- for i = 1, #Payment do
- if name == Payment[i][1] then Worth = Payment[i][2] end
- end
- return Worth
- end
- local function CountCash(Target)
- local Pay = 0
- for slot, item in pairs(PayChest.list()) do
- Pay = Pay + (CurrencyCheck(item.name) * item.count)
- end
- Pass = false
- if Pay >= Target then Pass = true end
- return Pass
- end
- local function TakePayment(Target)
- local Pay = 0
- Pass = false
- for slot, item in pairs(PayChest.list()) do
- local Cash = CurrencyCheck(item.name)
- repeat
- if (Pay + Cash) <= Target then Pay = Pay + Cash TransferItem(slot,"PayChest",1) end
- until (Pay + Cash) > Target
- end
- if Pay == Target then Pass = true end
- return Pass
- end
- local function FindStoredItem(Name,amount)
- local F = 0
- for slot, item in pairs(StoreChest.list()) do
- if item.name == Name and F ~= amount then
- if item.count >= amount then
- F = amount
- TransferItem(slot,"StoreChest",F)
- else
- end
- end
- end
- end
- function TransferItem(slot,from,amount)
- if from == "PayChest" then
- PayChest.pushItems(peripheral.getName(StoreChest),slot,amount)
- else
- StoreChest.pushItems(peripheral.getName(PayChest),slot,amount)
- end
- end
- local function PurchaseLoad(item,price,amount)
- local Total = price + (price * GovEc.GetTax("sales"))
- if CountCash(Total) == true then
- print("Correct Amount")
- if TakePayment(Total) == true then
- FindStoredItem(item,amount)
- Receipt.PrintReceipt(Company,"Commercial Purchase","Purchase Receipt","n",{{item,amount,price}})
- end
- end
- end
- function Shop()
- end
- function Login()
- local Len = #Company + #Label + 17
- term.clear()
- term.setCursorPos(w/2 - Len/2,h/2 -1)
- print(Company.." - "..Label.." Shop Terminal")
- term.setCursorPos(w/2 - 6, h/2 + 1)
- print("press enter")
- repeat
- local a, b = os.pullEvent("key")
- until b == keys.enter
- local Sta = BankLogin()
- if Sta == true then Shop() end
- end
- function BankLogin()
- term.clear()
- term.setCursorPos(w/2 - 4,h/2)
- term.write("Bank Key:")
- local BV = BankNet.GetV()
- term.setCursorPos(w/2 - string.len(BV)/2,h/2 + 2)
- term.write(BV)
- term.setCursorPos(1,h/2 + 1)
- local input
- repeat
- input = read()
- until string.len(input) == 4
- local CKey = input
- local Result = BankNet.AuthenticateAccount(CKey)
- if Result == true then ClientBankKey = CKey end
- return Result
- end
- function Start()
- while true do
- Login()
- end
- end
- Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement