Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Accredito POS V2 lego11
- --VARIABILI
- local lbl = "BN Credit"
- local tabr = {}
- local mon = peripheral.wrap("left")
- mon.setTextScale(0.5)
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- mon.clear()
- mon.setCursorPos(1,1)
- end
- function monLinea1()
- mon.setCursorPos(1, 1)
- end
- function monLinea2()
- mon.setCursorPos(1, 2)
- end
- function monLinea3()
- mon.setCursorPos(1, 3)
- end
- function monLinea4()
- mon.setCursorPos(1, 4)
- end
- function cartaNonValida()
- clear()
- mon.write("Carta")
- monLinea2()
- mon.write("non")
- monLinea3()
- mon.write("valida!")
- print("Carta non valida o corrotta.")
- print("")
- print("Premere un tasto per uscire")
- os.pullEvent("key")
- clear()
- exit()
- end
- function cartaVuota()
- clear()
- mon.write("Carta")
- monLinea2()
- mon.write("vuota!")
- print("Carta smagnetizzata o vuota.")
- print("")
- print("Premere un tasto per uscire")
- os.pullEvent("key")
- clear()
- exit()
- end
- m = peripheral.wrap("right")
- clear()
- print("Accredito POS")
- print("")
- print("Inserire la carta")
- mon.write("Accredito:")
- monLinea2()
- mon.write("inserire")
- monLinea3()
- mon.write("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
- credito = tonumber(tab.v)
- clear()
- mon.write("Attendere")
- monLinea2()
- mon.write("Autorizzazione")
- monLinea3()
- mon.write("in corso")
- print("La carta ha un saldo di "..credito.." IC.")
- print("")
- print("Inserire l'importo da addebitare")
- prelievo=tonumber(read())
- clear()
- print("Inserire nuovamente la carta per confermare il pagamento")
- mon.write("Accredito di")
- monLinea2()
- mon.write(prelievo.." IC")
- monLinea3()
- mon.write("Inserire")
- monLinea4()
- mon.write("la carta")
- tabr.t = tab.t
- tabr.e = tab.e
- tabr.p = tab.p
- tabr.v = tostring(credito + prelievo)
- ncr = textutils.serialize(tabr)
- m.setInsertCardLight(true)
- m.beginWrite(ncr,lbl)
- os.pullEvent("mag_write_done")
- m.setInsertCardLight(false)
- clear()
- print("Accredito effettuato")
- mon.write("Accredito")
- monLinea2()
- mon.write("effettuato")
- sleep(2)
- clear()
- exit()
Advertisement
Add Comment
Please, Sign In to add comment