Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- (c) LEGO11
- --CONFIGURAZIONE
- --Inserire qui il titolo che appare sopra Inserire la carta
- print("Sistema badge")
- --Inserire qui i nomi che possono aprire la porta
- nome1 = "lego11"
- -- nome2 = ""
- -- nome3 = ""
- -- nome4 = ""
- --Inserire qui il lato dove la redstone viene attivata per aprire la porta
- latoRS = "back"
- --Inserire qui il lato del lettore magnetico
- latoLettore = "bottom"
- --Inserire qui il tempo per cui la porta rimane aperta dopo aver inserito la carta
- tempoApertura = 5
- --FINE CONFIGURAZIONE
- local tabr = {}
- local contanti = 0
- local conteggio = 0
- 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 cartaVuota()
- clear()
- print("Carta smagnetizzata.")
- print("")
- print("Premere un tasto per uscire")
- os.pullEvent("key")
- os.reboot()
- end
- function nomeNonAutorizzato()
- clear()
- print("Utente non autorizzato.")
- print("")
- print("Premere un tasto per uscire")
- os.pullEvent("key")
- os.reboot()
- end
- m = peripheral.wrap(latoLettore)
- clear()
- print(titolo)
- print("")
- print("Inserire la carta")
- 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 ~= "BA" then
- cartaNonValida()
- end
- if tab.e ~= "NA" then
- cartaNonValida()
- end
- if tab.n ~= nome1 or tab.n ~= nome2 or tab.n ~= nome3 then
- nomeNonAutorizzato()
- 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
- rs.setOutput(latoRS, true)
- sleep(tempoApertura)
- rs.setOutput(latoRS, false)
- sleep(1)
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment