Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Versamenti DIAMANTE V2 lego11
- --VARIABILI
- local lbl = "BN Credit"
- 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 accredita()
- tabr.t = tab.t
- tabr.e = tab.e
- tabr.p = tab.p
- tabr.v = tostring(credito + contanti)
- ncr = textutils.serialize(tabr)
- m.setInsertCardLight(true)
- m.beginWrite(ncr,lbl)
- os.pullEvent("mag_write_done")
- m.setInsertCardLight(false)
- end
- function oggettiEstranei()
- clear()
- print("ATTENZIONE: RILEVATI OGGETTI ESTRANEI NELLA CASSAFORTE VERSAMENTI")
- print("")
- redstone.setOutput("top", true)
- print("Rimuovere gli oggetti estranei e premere un tasto per uscire")
- print("")
- os.pullEvent("key")
- redstone.setOutput("top", false)
- sleep(1)
- os.reboot()
- end
- m = peripheral.wrap("right")
- clear()
- print("Banco di NEBRASKA - Sistema VERSAMENTI")
- 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 ~= "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)
- while true do
- print("La carta ha un saldo di "..credito.." IC.")
- print("")
- print("Per favore scegliere un'opzione utilizzando i tasti numerici e confermare con ENTER:")
- print("")
- print("[1] Versare dei contanti (SOLO IC di DIAMANTE!)")
- print("[2] Annullare il versamento")
- num=tonumber(read())
- if num == 1 then
- redstone.setOutput("top", true)
- print("Inserire i contanti nello sportello sotto questo computer.")
- print("")
- print("AVVERTENZA IMPORTANTE:")
- print("Inserire SOLO Industrial Credit (IC) DI DIAMANTE IN MULTIPLI DI 16 (minimo: 16 ICD o 8192 IC)")
- print("")
- print("NON INSERIRE ASSOLUTAMENTE:")
- print("- IC di rame, di inox, d'argento, d'oro")
- print("- IC di diamante in stack NON MULTIPLI DI 16")
- print("- Minerali")
- print("- Altri oggetti")
- print("")
- print("L'inserimento di oggetti errati comporta LA PERDITA TOTALE DEL VERSAMENTO.")
- print("")
- print("Quando si è pronti per continuare, premere un tasto qualsiasi.")
- os.pullEvent("key")
- clear()
- redstone.setOutput("top", false)
- if redstone.getInput("left") == false then
- print("Errore: nessun contante inserito")
- print("")
- print("Premere un tasto qualsiasi per uscire")
- print("")
- os.pullEvent("key")
- os.reboot()
- end
- print("Conteggio contanti in corso...")
- print("")
- while redstone.getInput("left") == true do
- redstone.setOutput("back", true)
- sleep(0.25)
- redstone.setOutput("back", false)
- contanti = contanti+8192
- conteggio = conteggio+1
- sleep(0.25)
- term.setCursorPos(1,3)
- print("Contati "..contanti.." IC")
- if conteggio > 38 then
- oggettiEstranei()
- end
- end
- clear()
- print("Totale versato: "..contanti.." IC")
- print("")
- print("Inserire nuovamente la carta per accreditare il totale")
- accredita()
- clear()
- print("Denaro versato.")
- print("")
- print("Vecchio saldo: "..credito.." IC")
- print("Nuovo saldo : "..tabr.v.." IC")
- print("")
- print("Grazie!")
- sleep(5)
- os.reboot()
- elseif num == 2 then clear() break end
- end
- clear()
- print("Attendere")
- sleep(1)
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement