Advertisement
Marlingaming

Consumer Commercial Shopping terminal

Nov 27th, 2022 (edited)
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. --Edit This\/
  2. local Items = {} --item tag, display name, {amount per sale, cost, max sale},available
  3. local BankNet_En = false
  4. local BankKey = 0001
  5. local ShopFile = "Products.txt"
  6. --DONT TOUCH
  7. 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}}
  8. local Version = "1.2.0"
  9. local ClientBankKey
  10. local w, h = term.getSize()
  11. --Change to sides of computer for chests
  12. local PayChest = peripheral.wrap("top")
  13. local StoreChest = peripheral.wrap("bottom")
  14. --Your Name
  15. local Owner = "Marlin"
  16. --Company
  17. local Company = "WST"
  18. local Label = "Example"
  19.  
  20.  
  21. --DONT TOUCH ANYTHING BEYOND THIS
  22. local function start()
  23. for i = 1, #Items do
  24. local Amount = 0
  25. for slot, item in pairs(StoreChest.list()) do
  26. if item.name == Items[i][1] then Amount = Amount + item.count end
  27. end
  28. if Amount >= Items[i][3] then Storage[i] = true else Storage[i] = false end
  29. end
  30. if Receipt.CheckPrinter() == false then error("printer error") end
  31. Menu()
  32. Options()
  33. end
  34.  
  35. local function CurrencyCheck(name)
  36. local Worth = 0
  37. for i = 1, #Payment do
  38. if name == Payment[i][1] then Worth = Payment[i][2] end
  39. end
  40. return Worth
  41. end
  42.  
  43. local function CountCash(Target)
  44. local Pay = 0
  45. for slot, item in pairs(PayChest.list()) do
  46. Pay = Pay + (CurrencyCheck(item.name) * item.count)
  47. end
  48. Pass = false
  49. if Pay >= Target then Pass = true end
  50. return Pass
  51. end
  52.  
  53. local function TakePayment(Target)
  54. local Pay = 0
  55. Pass = false
  56. for slot, item in pairs(PayChest.list()) do
  57. local Cash = CurrencyCheck(item.name)
  58. repeat
  59. if (Pay + Cash) <= Target then Pay = Pay + Cash TransferItem(slot,"PayChest",1) end
  60. until (Pay + Cash) > Target
  61. end
  62. if Pay == Target then Pass = true end
  63. return Pass
  64. end
  65.  
  66. local function FindStoredItem(Name,amount)
  67. local F = 0
  68. for slot, item in pairs(StoreChest.list()) do
  69. if item.name == Name and F ~= amount then
  70. if item.count >= amount then
  71. F = amount
  72. TransferItem(slot,"StoreChest",F)
  73. else
  74.  
  75. end
  76. end
  77. end
  78. end
  79.  
  80. function TransferItem(slot,from,amount)
  81. if from == "PayChest" then
  82. PayChest.pushItems(peripheral.getName(StoreChest),slot,amount)
  83. else
  84. StoreChest.pushItems(peripheral.getName(PayChest),slot,amount)
  85. end
  86. end
  87.  
  88.  
  89. local function PurchaseLoad(item,price,amount)
  90. local Total = price + (price * GovEc.GetTax("sales"))
  91. if CountCash(Total) == true then
  92. print("Correct Amount")
  93. if TakePayment(Total) == true then
  94. FindStoredItem(item,amount)
  95. Receipt.PrintReceipt(Company,"Commercial Purchase","Purchase Receipt","n",{{item,amount,price}})
  96. end
  97. end
  98. end
  99.  
  100.  
  101.  
  102.  
  103. function Shop()
  104.  
  105. end
  106.  
  107. function Login()
  108. local Len = #Company + #Label + 17
  109. term.clear()
  110. term.setCursorPos(w/2 - Len/2,h/2 -1)
  111. print(Company.." - "..Label.." Shop Terminal")
  112. term.setCursorPos(w/2 - 6, h/2 + 1)
  113. print("press enter")
  114. repeat
  115. local a, b = os.pullEvent("key")
  116. until b == keys.enter
  117. local Sta = BankLogin()
  118. if Sta == true then Shop() end
  119. end
  120.  
  121. function BankLogin()
  122. term.clear()
  123. term.setCursorPos(w/2 - 4,h/2)
  124. term.write("Bank Key:")
  125.  
  126. local BV = BankNet.GetV()
  127. term.setCursorPos(w/2 - string.len(BV)/2,h/2 + 2)
  128. term.write(BV)
  129.  
  130. term.setCursorPos(1,h/2 + 1)
  131. local input
  132.  
  133. repeat
  134. input = read()
  135. until string.len(input) == 4
  136. local CKey = input
  137. local Result = BankNet.AuthenticateAccount(CKey)
  138. if Result == true then ClientBankKey = CKey end
  139. return Result
  140. end
  141.  
  142. function Start()
  143. while true do
  144. Login()
  145. end
  146. end
  147.  
  148. Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement