Marlingaming

Credit Card Reading Cashregister Mk 1 SCS3

Sep 7th, 2021 (edited)
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.34 KB | None | 0 0
  1. --this program deals with Cash Transfers, as sort of a Cash Register, or a Card Swipe, WIP
  2. Settings_AccountID = "Guest"
  3. Settings_PaymentMode = 0--0= Set Price, 1 = Choose item, 2 = Quanity of Item
  4. Settings_AdminCode = 0000
  5. Settings_Prices = [1,1,1,1,1]--prices for sold items
  6. Settings_Products = ["item","item","item","item","item"]
  7. Settings_CashRegisterState = "Closed"--Open or closed, closed will prevent any Use from Customers.
  8. --Sells
  9. Temp_Items = nil
  10. Temp_Total = 0
  11. Temp_CustomerAccount = nil
  12. local monitor = peripheral.find("monitor")
  13. start()
  14. function start()
  15.     term.clear()
  16.     Display("State")
  17.     if Settings_CashRegiserState == "Open" then
  18.         Standby()
  19.     else
  20.         print("this Register is Currently Closed")
  21.     end
  22. end
  23.  
  24. function Standby()
  25.     term.clear()
  26.     print("Please Wait for Cashier")
  27.     local event, key = os.pullEvent("key")
  28.     while true do
  29.         Display("Total")
  30.         if key == keys.1 then
  31.             TempTotal = TempTotal + Settings_Prices[0]
  32.         else if key == keys.2 && Settings_PaymentMode == 1 && Settings_Prices[1] != nil then
  33.             TempTotal = TempTotal + Settings_Prices[1]
  34.         else if key == keys.3 && Settings_PaymentMode == 1 && Settings_Prices[2] != nil then
  35.             TempTotal = TempTotal + Settings_Prices[2]
  36.         else if key == keys.4 && Settings_PaymentMode == 1 && Settings_Prices[3] != nil then
  37.             TempTotal = TempTotal + Settings_Prices[3]
  38.         else if key == keys.5 && Settings_PaymentMode == 1 && Settings_Prices[4] != nil then
  39.             TempTotal = TempTotal + Settings_Prices[4]
  40.         else if key == keys.enter then
  41.             break
  42.             sleep(20)
  43.             CreditReader()
  44.         end
  45.     end
  46. end
  47.  
  48. function CreditReader()
  49.     print("Waiting for Customer to Insert Credit Card")
  50.     Display("Write","Insert Card")
  51.     while true do
  52.                              
  53.     end
  54. end
  55.  
  56. function Display(Action,Text)
  57.     if Action == "Write" then
  58.         monitor.setCursorPos(1,1)
  59.         monitor.write(Text)
  60.     else if Action == "Clear" then
  61.         monitor.clear()
  62.     else if Action == "Total" then
  63.         monitor.setCursorPos(1,1)
  64.         monitor.write(Temp_Total)
  65.     else if Action == "State" then
  66.         monitor.clear()
  67.         monitor.setCursorPos(1,1)
  68.         if Settings_CashRegisterState == "Open" then
  69.             monitor.write("REGISTER IS OPEN")
  70.         else if Settings_CashRegisterState == "Closed" then
  71.             monitor.write("THIS REGISTER IS CLOSED")
  72.         end
  73.     end
  74. end
  75.  
  76. function PaymentHandler()
  77.  
  78. end
  79.  
  80. function ErrorHandler()
  81.  
  82. end
  83.  
Add Comment
Please, Sign In to add comment