SHOW:
|
|
- or go back to the newest paste.
| 1 | - | local valore = 0 |
| 1 | + | --Versamenti ORO V2 lego11 |
| 2 | - | print("Inserire oggetti")
|
| 2 | + | --VARIABILI |
| 3 | local lbl = "BN Credit" | |
| 4 | local tabr = {}
| |
| 5 | - | print("Premere un tasto quando gli oggetti sono stati inseriti")
|
| 5 | + | local contanti = 0 |
| 6 | local conteggio = 0 | |
| 7 | ||
| 8 | function clear() | |
| 9 | - | print("Nessun oggetto inserito")
|
| 9 | + | term.clear() |
| 10 | - | exit() |
| 10 | + | term.setCursorPos(1,1) |
| 11 | end | |
| 12 | ||
| 13 | - | redstone.setOutput("back", true)
|
| 13 | + | function pinErrato() |
| 14 | - | sleep(0.25) |
| 14 | + | clear() |
| 15 | - | redstone.setOutput("back", false)
|
| 15 | + | print("Errore di verifica del PIN")
|
| 16 | - | valore = valore+16 |
| 16 | + | |
| 17 | - | sleep(0.25) |
| 17 | + | print("Premere un tasto per uscire")
|
| 18 | - | print(valore) |
| 18 | + | |
| 19 | os.reboot() | |
| 20 | - | print(valore) |
| 20 | + | |
| 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 INOX!)")
| |
| 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) normali (di inox) IN MULTIPLI DI 16 (minimo: 16 IC)")
| |
| 126 | print("")
| |
| 127 | print("NON INSERIRE ASSOLUTAMENTE:")
| |
| 128 | print("- IC di rame, d'oro, d'argento, di diamante")
| |
| 129 | print("- IC di inox 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+16 | |
| 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 | clear() | |
| 168 | ||
| 169 | contanti = contanti - 16 | |
| 170 | ||
| 171 | print("Totale versato: "..contanti.." IC")
| |
| 172 | print("")
| |
| 173 | print("Inserire nuovamente la carta per accreditare il totale")
| |
| 174 | accredita() | |
| 175 | clear() | |
| 176 | print("Denaro versato.")
| |
| 177 | print("")
| |
| 178 | print("Vecchio saldo: "..credito.." IC")
| |
| 179 | print("Nuovo saldo : "..tabr.v.." IC")
| |
| 180 | print("")
| |
| 181 | print("Grazie!")
| |
| 182 | sleep(5) | |
| 183 | os.reboot() | |
| 184 | elseif num == 2 then clear() break end | |
| 185 | end | |
| 186 | clear() | |
| 187 | print("Attendere")
| |
| 188 | sleep(1) | |
| 189 | os.reboot() |