Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Convertitore carte
- --VARIABILI
- local tabr = {}
- m = peripheral.wrap("bottom")
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function pinErrato()
- clear()
- print("Errore di verifica del PIN")
- print("")
- print("Premere un tasto per uscire")
- os.pullEvent("key")
- os.reboot()
- end
- function cartaNonValida()
- clear()
- print("Carta non valida o corrotta.")
- print("")
- print("Premere un tasto per uscire")
- os.pullEvent("key")
- os.reboot()
- end
- function cartaGiaNuova()
- clear()
- print("Carta già convertita.")
- print("")
- print("Premere un tasto per uscire")
- os.pullEvent("key")
- os.reboot()
- end
- function cartaVuota()
- clear()
- print("Carta smagnetizzata o vuota.")
- print("")
- print("Premere un tasto per uscire")
- os.pullEvent("key")
- os.reboot()
- end
- function errore(errore)
- sfondo(colors.white)
- colore(colors.black)
- term.clear()
- term.setCursorPos(1, 1)
- term.write("Errore irreversibile")
- term.setCursorPos(1, 3)
- sfondo(colors.black)
- colore(colors.white)
- print(errore)
- print("\n\n\nAttendere qualche secondo...")
- os.sleep(5)
- os.reboot()
- end
- clear()
- print("Banco di NEBRASKA - Sistema BANCOMAT(R)")
- print("")
- print("Inserire la carta per attivarla o convertirla")
- m.setInsertCardLight(true)
- za,rawcarta = os.pullEvent("mag_swipe")
- m.setInsertCardLight(false)
- if rawcarta == nil then
- cartaVuota()
- end
- tab = textutils.unserialize(rawcarta)
- if type(tab) ~= "table" then
- cartaNonValida()
- end
- if tab.t == "cd" then
- cartaGiaNuova()
- end
- if tab.t ~= "cc" then
- cartaNonValida()
- end
- if tab.e ~= "BN" then
- cartaNonValida()
- end
- if tab.p ~= "0000" then
- print("")
- print("Inserire il PIN e premere ENTER")
- print("")
- local pinUtente = read("#")
- if pinUtente ~= tab.p then
- pinErrato()
- end
- end
- credito = tonumber(tab.v)
- sibRaw = http.get("http://luanet.rgbcraft.com/servlets/carte_debito.php?richiesta=crea&auth=EAD&valore="..credito).readAll()
- sib = textutils.unserialize(sibRaw)
- if type(sib) ~= "table" then
- errore("Impossibile comunicare con il server interbancario")
- end
- if sib.stato ~= "OK" then
- error("Errore irreversibile durante l'attivazione")
- end
- clear()
- print("Inserire nuovamente la carta per completare l'attivazione")
- tabr.t = "cd"
- tabr.e = tab.e
- tabr.p = tab.p
- tabr.v = sib.uuid
- local lbl = "BN Debit Card *" .. string.sub(tostring(sib.uuid), -4)
- ncr = textutils.serialize(tabr)
- m.setInsertCardLight(true)
- m.beginWrite(ncr,lbl)
- os.pullEvent("mag_write_done")
- m.setInsertCardLight(false)
- print("")
- print("Tra poco sarà possibile eseguire un'altra operazione.")
- sleep(5)
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment