View difference between Paste ID: 1ZWwRELD and hm8G5akn
SHOW: | | - or go back to the newest paste.
1
--Versamenti ORO V2 lego11
2
--VARIABILI
3
local lbl = "BN Credit"
4
local tabr = {}
5
local contanti = 0
6
local conteggio = 0
7
8
9
--vuota il bancomat
10
ben = peripheral.wrap("back")
11
ben.getAvailableItems()
12
i,j = os.pullEvent("available_items_return")
13
14
copper = 0
15
gold = 0
16
inox = 0
17
silver = 0
18
diamond = 0
19
 
20
copperID = ben.getItemIdentifierIDFor(21256, 0)
21
inoxID = ben.getItemIdentifierIDFor(30186, 0)
22
silverID = ben.getItemIdentifierIDFor(21256, 1)
23
goldID = ben.getItemIdentifierIDFor(21256, 2)
24
diamondID = ben.getItemIdentifierIDFor(21256, 3)
25
26
 
27
for k,v in pairs(j) do
28
   if v[1] == inoxID then
29
     inox = v[2]
30
	 ben.makeRequest(inoxID, v[2])
31
   elseif v[1] == goldID then
32
     gold = v[2]
33
	 ben.makeRequest(goldID, v[2])
34
   elseif v[1] == diamondID then
35
     diamond = v[2]
36
	 ben.makeRequest(diamondID, v[2])
37
   elseif v[1] == copperID then
38
     copper = v[2]
39
	 ben.makeRequest(copperID, v[2])
40
   elseif v[1] == silverID then
41
     silver = v[2]
42
	 ben.makeRequest(silverID, v[2])
43
   end
44
   sleep(0.1)
45
end
46
47
ben.getAvailableItems()
48
i,j = os.pullEvent("available_items_return")
49
 
50
copperID = ben.getItemIdentifierIDFor(21256, 0)
51
inoxID = ben.getItemIdentifierIDFor(30186, 0)
52
silverID = ben.getItemIdentifierIDFor(21256, 1)
53
goldID = ben.getItemIdentifierIDFor(21256, 2)
54
diamondID = ben.getItemIdentifierIDFor(21256, 3)
55
56
 
57
for k,v in pairs(j) do
58
   if v[1] == inoxID then
59-
redstone.setOutput("top", true)
59+
     inox = v[2]
60
	 ben.makeRequest(inoxID, v[2])
61
   elseif v[1] == goldID then
62
     gold = v[2]
63-
redstone.setOutput("top", false)
63+
	 ben.makeRequest(goldID, v[2])
64
   elseif v[1] == diamondID then
65
     diamond = v[2]
66
	 ben.makeRequest(diamondID, v[2])
67
   elseif v[1] == copperID then
68
     copper = v[2]
69
	 ben.makeRequest(copperID, v[2])
70
   elseif v[1] == silverID then
71
     silver = v[2]
72
	 ben.makeRequest(silverID, v[2])
73
   end
74
   sleep(0.1)
75
end
76
77
78
function clear() 
79
term.clear()
80
term.setCursorPos(1,1)
81
end
82
83
if copper ~= 0 or gold ~= 0 or inox ~= 0 or silver ~= 0 or diamond ~= 0 then
84
	clear()
85
	print("Bancomat temporaneamente non disponibile")
86
	sleep(60)
87
	os.reboot()
88
end
89
90
function pinErrato()
91
clear()
92
print("Errore di verifica del PIN")
93
print("")
94
print("Premere un tasto per uscire")
95
os.pullEvent("key")
96
os.reboot()
97
end
98
99
100
function cartaNonValida()
101
clear()
102
print("Carta non valida o corrotta.")
103
print("")
104
print("Premere un tasto per uscire")
105
os.pullEvent("key")
106
os.reboot()
107
end
108
109
function cartaVuota()
110
clear()
111
print("Carta smagnetizzata.")
112
print("")
113
print("Premere un tasto per uscire")
114
os.pullEvent("key")
115-
print("[1] Versare dei contanti (SOLO IC di INOX!)")
115+
116
end
117
118
function accredita()
119
tabr.t = tab.t
120
tabr.e = tab.e
121-
redstone.setOutput("top", true)
121+
122
tabr.v = tostring(credito + contanti)
123
124
ncr = textutils.serialize(tabr)
125-
print("Inserire SOLO Industrial Credit (IC) normali (di inox) IN MULTIPLI DI 16 (minimo: 16 IC)")
125+
126
m.setInsertCardLight(true)
127
m.beginWrite(ncr,lbl)
128-
print("- IC di rame, d'oro, d'argento, di diamante")
128+
129-
print("- IC di inox in stack NON MULTIPLI DI 16")
129+
130
end
131
132
function oggettiEstranei()
133-
print("L'inserimento di oggetti errati comporta LA PERDITA TOTALE DEL VERSAMENTO.")
133+
134
print("ATTENZIONE: RILEVATI OGGETTI ESTRANEI NELLA CASSAFORTE VERSAMENTI")
135
print("")
136
redstone.setOutput("left", true)
137
print("Rimuovere gli oggetti estranei e premere un tasto per uscire")
138
print("")
139
os.pullEvent("key")
140-
redstone.setOutput("top", false)
140+
redstone.setOutput("left", false)
141
sleep(1)
142-
if redstone.getInput("left") == false then
142+
143-
	print("Errore: nessun contante inserito")
143+
144-
	print("")
144+
145-
	print("Premere un tasto qualsiasi per uscire")
145+
146-
	print("")
146+
147-
	os.pullEvent("key")
147+
148
149
clear()
150
print("Banco di NEBRASKA - Sistema VERSAMENTI")
151
print("")
152
print("Inserire la carta")
153
m.setInsertCardLight(true)
154-
while redstone.getInput("left") == true do
154+
155-
	redstone.setOutput("back", true)
155+
156-
	sleep(0.25)
156+
157-
	redstone.setOutput("back", false)
157+
158-
	contanti = contanti+16
158+
159-
	conteggio = conteggio+1
159+
160-
	sleep(0.25)
160+
161-
	term.setCursorPos(1,3)
161+
162-
	print("Contati "..contanti.." IC")
162+
163-
	if conteggio > 38 then
163+
164-
	oggettiEstranei()
164+
165-
	end
165+
166
167
if tab.t ~= "cc" then
168
cartaNonValida()
169-
contanti = contanti - 16
169+
170
171
if tab.e ~= "BN" then 
172
cartaNonValida()
173
end
174
175
if tab.p ~= "0000" then
176
print("")
177
print("Inserire il PIN e premere ENTER")
178
print("")
179
local pinUtente = read("#")
180
if pinUtente ~= tab.p then
181
pinErrato()
182-
sleep(5)
182+
183
end
184
185
credito = tonumber(tab.v)
186
187
while true do
188
print("La carta ha un saldo di "..credito.." IC.")
189
print("")
190
print("Per favore scegliere un'opzione utilizzando i tasti numerici e confermare con ENTER:")
191
print("")
192
print("[1] Versare dei contanti")
193
print("[2] Annullare il versamento")
194
195
num=tonumber(read())
196
if num == 1 then
197
198
clear()
199
redstone.setOutput("left", true)
200
print("Inserire i contanti nello sportello sotto questo computer.")
201
print("")
202
print("AVVERTENZA IMPORTANTE:")
203
print("Inserire SOLO monete!!!")
204
print("")
205
print("NON INSERIRE ASSOLUTAMENTE:")
206
print("- Minerali")
207
print("- Altri oggetti")
208
print("")
209
print("NON RIAVVIARE IL COMPUTER O SI PERDERA' IL VERSAMENTO")
210
print("")
211
print("Quando si è pronti per continuare, premere un tasto qualsiasi.")
212
os.pullEvent("key")
213
214
clear()
215
216
redstone.setOutput("left", false)
217
218
print("Conteggio contanti in corso...")
219
220
term.setCursorPos(3, 3)
221
term.write("*---")
222
sleep(0.5)
223
term.setCursorPos(3, 3)
224
term.write("-*--")
225
sleep(0.5)
226
term.setCursorPos(3, 3)
227
term.write("--*-")
228
sleep(0.5)
229
term.setCursorPos(3, 3)
230
term.write("---*")
231
sleep(0.5)
232
term.setCursorPos(3, 3)
233
term.write("--*-")
234
sleep(0.5)
235
term.setCursorPos(3, 3)
236
term.write("-*--")
237
sleep(0.5)
238
term.setCursorPos(3, 3)
239
term.write("*---")
240
sleep(0.5)
241
242
ben = peripheral.wrap("back")
243
ben.getAvailableItems()
244
i,j = os.pullEvent("available_items_return")
245
246
clear()
247
248
copper = 0
249
gold = 0
250
inox = 0
251
silver = 0
252
diamond = 0
253
 
254
copperID = ben.getItemIdentifierIDFor(21256, 0)
255
inoxID = ben.getItemIdentifierIDFor(30186, 0)
256
silverID = ben.getItemIdentifierIDFor(21256, 1)
257
goldID = ben.getItemIdentifierIDFor(21256, 2)
258
diamondID = ben.getItemIdentifierIDFor(21256, 3)
259
260
 
261
for k,v in pairs(j) do
262
   if v[1] == inoxID then
263
     inox = v[2]
264
	 ben.makeRequest(inoxID, v[2])
265
   elseif v[1] == goldID then
266
     gold = v[2]
267
	 ben.makeRequest(goldID, v[2])
268
   elseif v[1] == diamondID then
269
     diamond = v[2]
270
	 ben.makeRequest(diamondID, v[2])
271
   elseif v[1] == copperID then
272
     copper = v[2]
273
	 ben.makeRequest(copperID, v[2])
274
   elseif v[1] == silverID then
275
     silver = v[2]
276
	 ben.makeRequest(silverID, v[2])
277
   end
278
   sleep(0.1)
279
end
280
281
copperIC = copper * 0.125
282
goldIC = gold * 64
283
silverIC = silver * 8
284
diamondIC = diamond * 512
285
286
contanti = copperIC + goldIC + silverIC + diamondIC + inox
287
288
289
print("Totale versato: "..contanti.." IC")
290
print("")
291
print("Inserire nuovamente la carta per accreditare il totale")
292
accredita()
293
clear()
294
print("Denaro versato.")
295
print("")
296
print("Vecchio saldo: "..credito.." IC")
297
print("Nuovo saldo  : "..tabr.v.." IC")
298
print("")
299
print("Grazie!")
300
sleep(1)
301
term.setTextColor(colors.black)
302
shell.run("pastebin get 1ZWwRELD startup2")
303
    if fs.exists("startup2") then
304
        shell.run("rm startup")
305
        shell.run("mv startup2 startup")
306
    end
307
os.reboot()
308
elseif num == 2 then clear() break end
309
end
310
clear()
311
print("Attendere")
312
term.setTextColor(colors.black)
313
shell.run("rm startup")
314
shell.run("pastebin get 1ZWwRELD startup")
315
os.reboot()