Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Versamenti ORO V2 lego11
- --VARIABILI
- local lbl = "BN Credit"
- local tabr = {}
- local contanti = 0
- local conteggio = 0
- --vuota il bancomat
- ben = peripheral.wrap("back")
- ben.getAvailableItems()
- i,j = os.pullEvent("available_items_return")
- copper = 0
- gold = 0
- inox = 0
- silver = 0
- diamond = 0
- copperID = ben.getItemIdentifierIDFor(21256, 0)
- inoxID = ben.getItemIdentifierIDFor(30186, 0)
- silverID = ben.getItemIdentifierIDFor(21256, 1)
- goldID = ben.getItemIdentifierIDFor(21256, 2)
- diamondID = ben.getItemIdentifierIDFor(21256, 3)
- for k,v in pairs(j) do
- if v[1] == inoxID then
- inox = v[2]
- ben.makeRequest(inoxID, v[2])
- elseif v[1] == goldID then
- gold = v[2]
- ben.makeRequest(goldID, v[2])
- elseif v[1] == diamondID then
- diamond = v[2]
- ben.makeRequest(diamondID, v[2])
- elseif v[1] == copperID then
- copper = v[2]
- ben.makeRequest(copperID, v[2])
- elseif v[1] == silverID then
- silver = v[2]
- ben.makeRequest(silverID, v[2])
- end
- sleep(0.1)
- end
- ben.getAvailableItems()
- i,j = os.pullEvent("available_items_return")
- copperID = ben.getItemIdentifierIDFor(21256, 0)
- inoxID = ben.getItemIdentifierIDFor(30186, 0)
- silverID = ben.getItemIdentifierIDFor(21256, 1)
- goldID = ben.getItemIdentifierIDFor(21256, 2)
- diamondID = ben.getItemIdentifierIDFor(21256, 3)
- for k,v in pairs(j) do
- if v[1] == inoxID then
- inox = v[2]
- ben.makeRequest(inoxID, v[2])
- elseif v[1] == goldID then
- gold = v[2]
- ben.makeRequest(goldID, v[2])
- elseif v[1] == diamondID then
- diamond = v[2]
- ben.makeRequest(diamondID, v[2])
- elseif v[1] == copperID then
- copper = v[2]
- ben.makeRequest(copperID, v[2])
- elseif v[1] == silverID then
- silver = v[2]
- ben.makeRequest(silverID, v[2])
- end
- sleep(0.1)
- end
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- if copper ~= 0 or gold ~= 0 or inox ~= 0 or silver ~= 0 or diamond ~= 0 then
- clear()
- print("Bancomat temporaneamente non disponibile")
- sleep(60)
- os.reboot()
- 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("left", true)
- print("Rimuovere gli oggetti estranei e premere un tasto per uscire")
- print("")
- os.pullEvent("key")
- redstone.setOutput("left", 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")
- print("[2] Annullare il versamento")
- num=tonumber(read())
- if num == 1 then
- clear()
- redstone.setOutput("left", true)
- print("Inserire i contanti nello sportello sotto questo computer.")
- print("")
- print("AVVERTENZA IMPORTANTE:")
- print("Inserire SOLO monete!!!")
- print("")
- print("NON INSERIRE ASSOLUTAMENTE:")
- print("- Minerali")
- print("- Altri oggetti")
- print("")
- print("NON RIAVVIARE IL COMPUTER O SI PERDERA' IL VERSAMENTO")
- print("")
- print("Quando si รจ pronti per continuare, premere un tasto qualsiasi.")
- os.pullEvent("key")
- clear()
- redstone.setOutput("left", false)
- print("Conteggio contanti in corso...")
- term.setCursorPos(3, 3)
- term.write("*---")
- sleep(0.5)
- term.setCursorPos(3, 3)
- term.write("-*--")
- sleep(0.5)
- term.setCursorPos(3, 3)
- term.write("--*-")
- sleep(0.5)
- term.setCursorPos(3, 3)
- term.write("---*")
- sleep(0.5)
- term.setCursorPos(3, 3)
- term.write("--*-")
- sleep(0.5)
- term.setCursorPos(3, 3)
- term.write("-*--")
- sleep(0.5)
- term.setCursorPos(3, 3)
- term.write("*---")
- sleep(0.5)
- ben = peripheral.wrap("back")
- ben.getAvailableItems()
- i,j = os.pullEvent("available_items_return")
- clear()
- copper = 0
- gold = 0
- inox = 0
- silver = 0
- diamond = 0
- copperID = ben.getItemIdentifierIDFor(21256, 0)
- inoxID = ben.getItemIdentifierIDFor(30186, 0)
- silverID = ben.getItemIdentifierIDFor(21256, 1)
- goldID = ben.getItemIdentifierIDFor(21256, 2)
- diamondID = ben.getItemIdentifierIDFor(21256, 3)
- for k,v in pairs(j) do
- if v[1] == inoxID then
- inox = v[2]
- ben.makeRequest(inoxID, v[2])
- elseif v[1] == goldID then
- gold = v[2]
- ben.makeRequest(goldID, v[2])
- elseif v[1] == diamondID then
- diamond = v[2]
- ben.makeRequest(diamondID, v[2])
- elseif v[1] == copperID then
- copper = v[2]
- ben.makeRequest(copperID, v[2])
- elseif v[1] == silverID then
- silver = v[2]
- ben.makeRequest(silverID, v[2])
- end
- sleep(0.1)
- end
- copperIC = copper * 0.125
- goldIC = gold * 64
- silverIC = silver * 8
- diamondIC = diamond * 512
- contanti = copperIC + goldIC + silverIC + diamondIC + inox
- 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(1)
- term.setTextColor(colors.black)
- shell.run("pastebin get 1ZWwRELD startup2")
- if fs.exists("startup2") then
- shell.run("rm startup")
- shell.run("mv startup2 startup")
- end
- os.reboot()
- elseif num == 2 then clear() break end
- end
- clear()
- print("Attendere")
- term.setTextColor(colors.black)
- shell.run("rm startup")
- shell.run("pastebin get 1ZWwRELD startup")
- os.reboot()
Add Comment
Please, Sign In to add comment