SHOW:
|
|
- or go back to the newest paste.
1 | - | --Versamenti ORO V2 lego11 |
1 | + | --Versamenti DIAMANTE V2 lego11 |
2 | --VARIABILI | |
3 | local lbl = "BN Credit" | |
4 | local tabr = {} | |
5 | local contanti = 0 | |
6 | local conteggio = 0 | |
7 | ||
8 | function clear() | |
9 | term.clear() | |
10 | term.setCursorPos(1,1) | |
11 | end | |
12 | ||
13 | function pinErrato() | |
14 | clear() | |
15 | print("Errore di verifica del PIN") | |
16 | print("") | |
17 | print("Premere un tasto per uscire") | |
18 | os.pullEvent("key") | |
19 | os.reboot() | |
20 | end | |
21 | ||
22 | ||
23 | function cartaNonValida() | |
24 | clear() | |
25 | print("Carta non valida o corrotta.") | |
26 | print("") | |
27 | print("Premere un tasto per uscire") | |
28 | os.pullEvent("key") | |
29 | os.reboot() | |
30 | end | |
31 | ||
32 | function cartaVuota() | |
33 | clear() | |
34 | print("Carta smagnetizzata.") | |
35 | print("") | |
36 | print("Premere un tasto per uscire") | |
37 | os.pullEvent("key") | |
38 | os.reboot() | |
39 | end | |
40 | ||
41 | function accredita() | |
42 | tabr.t = tab.t | |
43 | tabr.e = tab.e | |
44 | tabr.p = tab.p | |
45 | tabr.v = tostring(credito + contanti) | |
46 | ||
47 | ncr = textutils.serialize(tabr) | |
48 | ||
49 | m.setInsertCardLight(true) | |
50 | m.beginWrite(ncr,lbl) | |
51 | os.pullEvent("mag_write_done") | |
52 | m.setInsertCardLight(false) | |
53 | end | |
54 | ||
55 | function oggettiEstranei() | |
56 | clear() | |
57 | print("ATTENZIONE: RILEVATI OGGETTI ESTRANEI NELLA CASSAFORTE VERSAMENTI") | |
58 | print("") | |
59 | redstone.setOutput("top", true) | |
60 | print("Rimuovere gli oggetti estranei e premere un tasto per uscire") | |
61 | print("") | |
62 | os.pullEvent("key") | |
63 | redstone.setOutput("top", false) | |
64 | sleep(1) | |
65 | os.reboot() | |
66 | end | |
67 | ||
68 | ||
69 | ||
70 | m = peripheral.wrap("right") | |
71 | ||
72 | clear() | |
73 | print("Banco di NEBRASKA - Sistema VERSAMENTI") | |
74 | print("") | |
75 | print("Inserire la carta") | |
76 | m.setInsertCardLight(true) | |
77 | za,rawcarta = os.pullEvent("mag_swipe") | |
78 | m.setInsertCardLight(false) | |
79 | ||
80 | if rawcarta == nil then | |
81 | cartaVuota() | |
82 | end | |
83 | ||
84 | tab = textutils.unserialize(rawcarta) | |
85 | ||
86 | if type(tab) ~= "table" then | |
87 | cartaNonValida() | |
88 | end | |
89 | ||
90 | if tab.t ~= "cc" then | |
91 | cartaNonValida() | |
92 | end | |
93 | ||
94 | if tab.e ~= "BN" then | |
95 | cartaNonValida() | |
96 | end | |
97 | ||
98 | if tab.p ~= "0000" then | |
99 | print("") | |
100 | print("Inserire il PIN e premere ENTER") | |
101 | print("") | |
102 | local pinUtente = read("#") | |
103 | if pinUtente ~= tab.p then | |
104 | pinErrato() | |
105 | end | |
106 | end | |
107 | ||
108 | credito = tonumber(tab.v) | |
109 | ||
110 | while true do | |
111 | print("La carta ha un saldo di "..credito.." IC.") | |
112 | print("") | |
113 | print("Per favore scegliere un'opzione utilizzando i tasti numerici e confermare con ENTER:") | |
114 | print("") | |
115 | - | print("[1] Versare dei contanti (SOLO IC di ORO!)") |
115 | + | print("[1] Versare dei contanti (SOLO IC di DIAMANTE!)") |
116 | print("[2] Annullare il versamento") | |
117 | ||
118 | num=tonumber(read()) | |
119 | if num == 1 then | |
120 | ||
121 | redstone.setOutput("top", true) | |
122 | print("Inserire i contanti nello sportello sotto questo computer.") | |
123 | print("") | |
124 | print("AVVERTENZA IMPORTANTE:") | |
125 | - | print("Inserire SOLO Industrial Credit (IC) D'ORO IN MULTIPLI DI 16 (minimo: 16 ICO o 1024 IC)") |
125 | + | print("Inserire SOLO Industrial Credit (IC) DI DIAMANTE IN MULTIPLI DI 16 (minimo: 16 ICD o 8192 IC)") |
126 | print("") | |
127 | print("NON INSERIRE ASSOLUTAMENTE:") | |
128 | - | print("- IC di rame, di inox, d'argento, di diamante") |
128 | + | print("- IC di rame, di inox, d'argento, d'oro") |
129 | - | print("- IC d'oro in stack NON MULTIPLI DI 16") |
129 | + | print("- IC di diamante in stack NON MULTIPLI DI 16") |
130 | print("- Minerali") | |
131 | print("- Altri oggetti") | |
132 | print("") | |
133 | print("L'inserimento di oggetti errati comporta LA PERDITA TOTALE DEL VERSAMENTO.") | |
134 | print("") | |
135 | print("Quando si รจ pronti per continuare, premere un tasto qualsiasi.") | |
136 | os.pullEvent("key") | |
137 | ||
138 | clear() | |
139 | ||
140 | redstone.setOutput("top", false) | |
141 | ||
142 | if redstone.getInput("left") == false then | |
143 | print("Errore: nessun contante inserito") | |
144 | print("") | |
145 | print("Premere un tasto qualsiasi per uscire") | |
146 | print("") | |
147 | os.pullEvent("key") | |
148 | os.reboot() | |
149 | end | |
150 | ||
151 | print("Conteggio contanti in corso...") | |
152 | print("") | |
153 | ||
154 | while redstone.getInput("left") == true do | |
155 | redstone.setOutput("back", true) | |
156 | sleep(0.25) | |
157 | redstone.setOutput("back", false) | |
158 | - | contanti = contanti+1024 |
158 | + | contanti = contanti+8192 |
159 | conteggio = conteggio+1 | |
160 | sleep(0.25) | |
161 | term.setCursorPos(1,3) | |
162 | print("Contati "..contanti.." IC") | |
163 | if conteggio > 38 then | |
164 | oggettiEstranei() | |
165 | end | |
166 | end | |
167 | ||
168 | clear() | |
169 | ||
170 | print("Totale versato: "..contanti.." IC") | |
171 | print("") | |
172 | print("Inserire nuovamente la carta per accreditare il totale") | |
173 | accredita() | |
174 | clear() | |
175 | print("Denaro versato.") | |
176 | print("") | |
177 | print("Vecchio saldo: "..credito.." IC") | |
178 | print("Nuovo saldo : "..tabr.v.." IC") | |
179 | print("") | |
180 | print("Grazie!") | |
181 | sleep(5) | |
182 | os.reboot() | |
183 | elseif num == 2 then clear() break end | |
184 | end | |
185 | clear() | |
186 | print("Attendere") | |
187 | sleep(1) | |
188 | os.reboot() |