lego11

Convertitore carte v2 v3

Oct 3rd, 2025 (edited)
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --Convertitore carte
  2. --VARIABILI
  3. local tabr = {}
  4.  
  5. m = peripheral.wrap("bottom")
  6.  
  7. function clear()
  8. term.clear()
  9. term.setCursorPos(1,1)
  10. end
  11.  
  12. function pinErrato()
  13. clear()
  14. print("Errore di verifica del PIN")
  15. print("")
  16. print("Premere un tasto per uscire")
  17. os.pullEvent("key")
  18. os.reboot()
  19. end
  20.  
  21.  
  22. function cartaNonValida()
  23. clear()
  24. print("Carta non valida o corrotta.")
  25. print("")
  26. print("Premere un tasto per uscire")
  27. os.pullEvent("key")
  28. os.reboot()
  29. end
  30.  
  31. function cartaGiaNuova()
  32. clear()
  33. print("Carta già convertita.")
  34. print("")
  35. print("Premere un tasto per uscire")
  36. os.pullEvent("key")
  37. os.reboot()
  38. end
  39.  
  40. function cartaVuota()
  41. clear()
  42. print("Carta smagnetizzata o vuota.")
  43. print("")
  44. print("Premere un tasto per uscire")
  45. os.pullEvent("key")
  46. os.reboot()
  47. end
  48.  
  49. function errore(errore)
  50.     sfondo(colors.white)
  51.     colore(colors.black)
  52.     term.clear()
  53.     term.setCursorPos(1, 1)
  54.     term.write("Errore irreversibile")
  55.     term.setCursorPos(1, 3)
  56.     sfondo(colors.black)
  57.     colore(colors.white)
  58.     print(errore)
  59.     print("\n\n\nAttendere qualche secondo...")
  60.     os.sleep(5)
  61.     os.reboot()
  62. end
  63.  
  64.  
  65. clear()
  66. print("Banco di NEBRASKA - Sistema BANCOMAT(R)")
  67. print("")
  68. print("Inserire la carta per attivarla o convertirla")
  69. m.setInsertCardLight(true)
  70. za,rawcarta = os.pullEvent("mag_swipe")
  71. m.setInsertCardLight(false)
  72.  
  73. if rawcarta == nil then
  74. cartaVuota()
  75. end
  76.  
  77. tab = textutils.unserialize(rawcarta)
  78.  
  79. if type(tab) ~= "table" then
  80. cartaNonValida()
  81. end
  82.  
  83. if tab.t == "cd" then
  84. cartaGiaNuova()
  85. end
  86.  
  87. if tab.t ~= "cc" then
  88. cartaNonValida()
  89. end
  90.  
  91. if tab.e ~= "BN" then
  92. cartaNonValida()
  93. end
  94.  
  95. if tab.p ~= "0000" then
  96. print("")
  97. print("Inserire il PIN e premere ENTER")
  98. print("")
  99. local pinUtente = read("#")
  100. if pinUtente ~= tab.p then
  101. pinErrato()
  102. end
  103. end
  104.  
  105. credito = tonumber(tab.v)
  106.  
  107. sibRaw = http.get("http://luanet.rgbcraft.com/servlets/carte_debito.php?richiesta=crea&auth=EAD&valore="..credito).readAll()
  108. sib = textutils.unserialize(sibRaw)
  109.  
  110. if type(sib) ~= "table" then
  111.     errore("Impossibile comunicare con il server interbancario")
  112. end
  113.  
  114. if sib.stato ~= "OK" then
  115.     error("Errore irreversibile durante l'attivazione")
  116. end
  117.  
  118. clear()
  119. print("Inserire nuovamente la carta per completare l'attivazione")
  120.  
  121. tabr.t = "cd"
  122. tabr.e = tab.e
  123. tabr.p = tab.p
  124. tabr.v = sib.uuid
  125.  
  126. local lbl = "BN Debit Card *" .. string.sub(tostring(sib.uuid), -4)
  127.  
  128. ncr = textutils.serialize(tabr)
  129.  
  130. m.setInsertCardLight(true)
  131. m.beginWrite(ncr,lbl)
  132. os.pullEvent("mag_write_done")
  133. m.setInsertCardLight(false)
  134.  
  135. print("")
  136. print("Tra poco sarà possibile eseguire un'altra operazione.")
  137. sleep(5)
  138. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment