lego11

Verifica Saldo V2

May 14th, 2018
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.69 KB | None | 0 0
  1. --Addebito POS V2 lego11
  2.  
  3. --VARIABILI
  4. local lbl = "BN Credit"
  5. local tabr = {}
  6. local mon = peripheral.wrap("left")
  7. mon.setTextScale(0.5)
  8. function clear()
  9. term.clear()
  10. term.setCursorPos(1,1)
  11. mon.clear()
  12. mon.setCursorPos(1,1)
  13. end
  14.  
  15. function monLinea1()
  16. mon.setCursorPos(1, 1)
  17. end
  18.  
  19. function monLinea2()
  20. mon.setCursorPos(1, 2)
  21. end
  22.  
  23. function monLinea3()
  24. mon.setCursorPos(1, 3)
  25. end
  26.  
  27. function monLinea4()
  28. mon.setCursorPos(1, 4)
  29. end
  30.  
  31. function cartaNonValida()
  32. clear()
  33. mon.write("Carta")
  34. monLinea2()
  35. mon.write("non")
  36. monLinea3()
  37. mon.write("valida!")
  38. print("Carta non valida o corrotta.")
  39. print("")
  40. print("Premere un tasto per uscire")
  41. os.pullEvent("key")
  42. clear()
  43. exit()
  44. end
  45.  
  46. function cartaVuota()
  47. clear()
  48. mon.write("Carta")
  49. monLinea2()
  50. mon.write("vuota!")
  51. print("Carta smagnetizzata o vuota.")
  52. print("")
  53. print("Premere un tasto per uscire")
  54. os.pullEvent("key")
  55. clear()
  56. exit()
  57. end
  58.  
  59.  
  60. m = peripheral.wrap("right")
  61. clear()
  62. print("Verifica SALDO")
  63. print("")
  64. print("Inserire la carta")
  65. mon.write("Saldo:")
  66. monLinea2()
  67. mon.write("inserire")
  68. monLinea3()
  69. mon.write("la carta")
  70.  
  71. m.setInsertCardLight(true)
  72. za,rawcarta = os.pullEvent("mag_swipe")
  73. m.setInsertCardLight(false)
  74.  
  75. if rawcarta == nil then
  76. cartaVuota()
  77. end
  78.  
  79. tab = textutils.unserialize(rawcarta)
  80.  
  81. if type(tab) ~= "table" then
  82. cartaNonValida()
  83. end
  84.  
  85. if tab.t ~= "cc" then
  86. cartaNonValida()
  87. end
  88.  
  89. if tab.e ~= "BN" then
  90. cartaNonValida()
  91. end
  92.  
  93. credito = tonumber(tab.v)
  94. clear()
  95. print("La carta ha un saldo di "..credito.." IC.")
  96. mon.write("Saldo carta:")
  97. monLinea2()
  98. mon.write(credito.." IC")
  99. monLinea3()
  100. print("")
  101. print("Premere un tasto per uscire")
  102. os.pullEvent("key")
  103. clear()
  104. exit()
Advertisement
Add Comment
Please, Sign In to add comment