View difference between Paste ID: 7Gkt97As and hm8G5akn
SHOW: | | - or go back to the newest paste.
1-
--Versamenti ORO V2 lego11
1+
-- (c) LEGO11
2-
--VARIABILI
2+
3-
local lbl = "BN Credit"
3+
--CONFIGURAZIONE
4
5
--Inserire qui il titolo che appare sopra Inserire la carta
6
print("Sistema badge")
7
8
--Inserire qui i nomi che possono aprire la porta
9
nome1 = "lego11"
10
-- nome2 = ""
11
-- nome3 = ""
12
-- nome4 = ""
13
14
--Inserire qui il lato dove la redstone viene attivata per aprire la porta
15
latoRS = "back"
16
17
--Inserire qui il lato del lettore magnetico
18
19
latoLettore = "bottom"
20
21
--Inserire qui il tempo per cui la porta rimane aperta dopo aver inserito la carta
22
23
tempoApertura = 5
24
25
--FINE CONFIGURAZIONE
26
27
28
local tabr = {}
29
local contanti = 0
30
local conteggio = 0
31
32
function clear() 
33
term.clear()
34
term.setCursorPos(1,1)
35
end
36
37
function pinErrato()
38
clear()
39
print("Errore di verifica del PIN")
40
print("")
41-
function accredita()
41+
42-
tabr.t = tab.t
42+
43-
tabr.e = tab.e
43+
44-
tabr.p = tab.p
44+
45-
tabr.v = tostring(credito + contanti)
45+
46
47-
ncr = textutils.serialize(tabr)
47+
48
clear()
49
print("Carta non valida o corrotta.")
50-
m.beginWrite(ncr,lbl)
50+
51-
os.pullEvent("mag_write_done")
51+
52
os.pullEvent("key")
53
os.reboot()
54
end
55-
function oggettiEstranei()
55+
56
function cartaVuota()
57-
print("ATTENZIONE: RILEVATI OGGETTI ESTRANEI NELLA CASSAFORTE VERSAMENTI")
57+
58
print("Carta smagnetizzata.")
59-
redstone.setOutput("top", true)
59+
60-
print("Rimuovere gli oggetti estranei e premere un tasto per uscire")
60+
61
os.pullEvent("key")
62
os.reboot()
63-
redstone.setOutput("top", false)
63+
64
65
function nomeNonAutorizzato()
66
clear()
67
print("Utente non autorizzato.")
68
print("")
69
print("Premere un tasto per uscire")
70-
m = peripheral.wrap("right") 
70+
71
os.reboot()
72
end
73-
print("Banco di NEBRASKA - Sistema VERSAMENTI")
73+
74
m = peripheral.wrap(latoLettore) 
75
76
clear()
77
print(titolo)
78
print("")
79
print("Inserire la carta")
80
m.setInsertCardLight(true)
81
za,rawcarta = os.pullEvent("mag_swipe")
82
m.setInsertCardLight(false)
83
84
if rawcarta == nil then
85
cartaVuota()
86
end
87
88
tab = textutils.unserialize(rawcarta)
89
90-
if tab.t ~= "cc" then
90+
91
cartaNonValida()
92
end
93
94-
if tab.e ~= "BN" then 
94+
if tab.t ~= "BA" then
95
cartaNonValida()
96
end
97
98
if tab.e ~= "NA" then 
99
cartaNonValida()
100
end
101
102
if tab.n ~= nome1 or tab.n ~= nome2 or tab.n ~= nome3 then
103
nomeNonAutorizzato()
104
end
105
106
if tab.p ~= "0000" then
107
print("")
108-
credito = tonumber(tab.v)
108+
109
print("")
110-
while true do
110+
111-
print("La carta ha un saldo di "..credito.." IC.")
111+
112
pinErrato()
113-
print("Per favore scegliere un'opzione utilizzando i tasti numerici e confermare con ENTER:")
113+
114
end
115-
print("[1] Versare dei contanti (SOLO IC di INOX!)")
115+
rs.setOutput(latoRS, true)
116-
print("[2] Annullare il versamento")
116+
sleep(tempoApertura)
117
rs.setOutput(latoRS, false)
118-
num=tonumber(read())
118+
119-
if num == 1 then
119+