lego11

Bancomat

May 11th, 2018 (edited)
521
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- BANCOMAT V2 aggiornato 2025 copyright lego11
  2. local tabr = {}
  3.  
  4. function clear()
  5.     term.clear()
  6.     term.setCursorPos(1, 1)
  7. end
  8.  
  9. function pinErrato()
  10.     clear()
  11.     print("Errore di verifica del PIN")
  12.     print("")
  13.     print("Premere un tasto per uscire")
  14.     os.pullEvent("key")
  15.     os.reboot()
  16. end
  17.  
  18. function cartaNonValida()
  19.     clear()
  20.     print("Carta non valida o corrotta.")
  21.     print("")
  22.     print("Premere un tasto per uscire")
  23.     os.pullEvent("key")
  24.     os.reboot()
  25. end
  26.  
  27. function cartaVuota()
  28.     clear()
  29.     print("Carta smagnetizzata o vuota.")
  30.     print("")
  31.     print("Premere un tasto per uscire")
  32.     os.pullEvent("key")
  33.     os.reboot()
  34. end
  35.  
  36. function cartaNoSIB()
  37.     clear()
  38.     print("Carta non in sistema interbancario.")
  39.     print("")
  40.     print("Premere un tasto per uscire")
  41.     os.pullEvent("key")
  42.     os.reboot()
  43. end
  44.  
  45. function sibFail()
  46.     clear()
  47.     print("Errore connessione sistema interbancario")
  48.     print("")
  49.     print("Premere un tasto per uscire")
  50.     os.pullEvent("key")
  51.     os.reboot()
  52. end
  53.  
  54. function cartaVecchia()
  55.     clear()
  56.     print("CARTA NON SICURA. Convertire la carta presso lo sportello situato in:\n")
  57.     print("\n Banco di Nebraska - P.zza Affari 3, New Radeon")
  58.     print("")
  59.     print("Premere un tasto per uscire")
  60.     os.pullEvent("key")
  61.     os.reboot()
  62. end
  63.  
  64. function preleva(prelievo, uuid)
  65.     clear()
  66.     erogati = 0
  67.     sibRaw = http.get("http://luanet.rgbcraft.com/servlets/carte_debito.php?richiesta=addebito&valore=" .. prelievo ..
  68.                           "&uuid=" .. uuid).readAll()
  69.     sib = textutils.unserialize(sibRaw)
  70.  
  71.     if type(sib) ~= "table" then
  72.         print("\n\n\nImpossibile comunicare con il server interbancario")
  73.         sleep(5)
  74.         os.reboot()
  75.     end
  76.  
  77.     if sib.stato == "DI" then
  78.         print("Disponibilità insufficiente")
  79.         sleep(5)
  80.     elseif sib.stato ~= "OK" then
  81.         print(
  82.             "\n\n\nLa carta non risulta nel sistema interbancario, potrebbe essere stata disabilitata per uso fraudolento")
  83.         sleep(5)
  84.         os.reboot()
  85.     else
  86.         print("Ritirare il denaro")
  87.         print("")
  88.         for i = prelievo, 1, -64 do
  89.             redstone.setOutput("bottom", true)
  90.             sleep(0.25)
  91.             erogati = erogati + 64
  92.             print("Erogati " .. erogati .. " IC")
  93.             redstone.setOutput("bottom", false)
  94.         end
  95.         print("")
  96.         term.setBackgroundColor(colors.white)
  97.         term.setTextColor(colors.black)
  98.         clear()
  99.         print("Prelievo effettuato\n")
  100.         print("Tra poco sarà possibile eseguire un'altra operazione.")
  101.  
  102.         term.setTextColor(colors.white)
  103.  
  104.         shell.run("pastebin get v84Q9wC1 startup2") -- Inserire paste di nPay
  105.         if fs.exists("startup2") then
  106.             shell.run("rm startup")
  107.             shell.run("mv startup2 startup")
  108.         end
  109.     end
  110. end
  111.  
  112. m = peripheral.wrap("right")
  113. lbl = "BN Credit"
  114.  
  115. clear()
  116. print("Banco di NEBRASKA - Sistema BANCOMAT(R)")
  117. print("")
  118. print("Inserire la carta")
  119. m.setInsertCardLight(true)
  120. za, rawcarta = os.pullEvent("mag_swipe")
  121. m.setInsertCardLight(false)
  122.  
  123. if rawcarta == nil then
  124.     cartaVuota()
  125. end
  126.  
  127. tab = textutils.unserialize(rawcarta)
  128.  
  129. if type(tab) ~= "table" then
  130.     cartaNonValida()
  131. end
  132.  
  133. if tab.t == "cc" then
  134.     cartaVecchia()
  135. end
  136.  
  137. if tab.t ~= "cd" then
  138.     cartaNonValida()
  139. end
  140.  
  141. if tab.e ~= "BN" then
  142.     cartaNonValida()
  143. end
  144.  
  145. sibRaw = http.get("http://luanet.rgbcraft.com/servlets/carte_debito.php?richiesta=verifica&uuid=" .. tab.v).readAll()
  146. sib = textutils.unserialize(sibRaw)
  147.  
  148. if type(sib) ~= "table" then
  149.     sibFail()
  150. end
  151. if sib.stato ~= "OK" then
  152.     cartaNoSIB()
  153. end
  154.  
  155. credito = tonumber(sib.saldo)
  156. carta = string.sub(tostring(tab.v), -4)
  157.  
  158. clear()
  159.  
  160. while true do
  161.     print("La carta *" .. carta .. " ha una disponibilità di " .. credito .. " IC.")
  162.     print("")
  163.     print("Per favore scegliere un'opzione utilizzando i tasti numerici e confermare con ENTER:")
  164.     print("")
  165.     print("[1] Preleva   64 IC")
  166.     print("[2] Preleva  128 IC")
  167.     print("[3] Preleva  256 IC")
  168.     print("[4] Preleva  512 IC")
  169.     print("[5] Preleva 4096 IC")
  170.     print("[6] Esci senza prelevare")
  171.     num = tonumber(read())
  172.     if num == 1 then
  173.         preleva(64, tab.v)
  174.         break
  175.     elseif num == 2 then
  176.         preleva(128, tab.v)
  177.         break
  178.     elseif num == 3 then
  179.         preleva(256, tab.v)
  180.         break
  181.     elseif num == 4 then
  182.         preleva(512, tab.v)
  183.         break
  184.     elseif num == 5 then
  185.         preleva(4096, tab.v)
  186.         break
  187.     elseif num == 6 then
  188.         clear()
  189.         break
  190.     end
  191. end
  192.  
  193. term.setBackgroundColor(colors.white)
  194. term.setTextColor(colors.black)
  195. clear()
  196. print("Tra poco sarà possibile eseguire un'altra operazione.")
  197.  
  198. term.setTextColor(colors.white)
  199.  
  200. shell.run("pastebin get v84Q9wC1 startup2") -- Inserire paste di nPay
  201. if fs.exists("startup2") then
  202.     shell.run("rm startup")
  203.     shell.run("mv startup2 startup")
  204. end
  205.  
  206. os.reboot()
  207.  
Advertisement
Add Comment
Please, Sign In to add comment