Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rs.setOutput("left", true)
- mag = peripheral.wrap("right")
- function accredita()
- term.clear()
- term.setCursorPos(1,1)
- print("Inserisci la carta")
- mag.setInsertCardLight(true)
- _, data, side = os.pullEvent("mag_swipe")
- mag.setInsertCardLight(false)
- tab = textutils.unserialize(data)
- if tab == nil or tab.credito == nil or tab.label == nil then
- print("Carta non valida!")
- sleep(2)
- os.reboot()
- end
- if tab.credito < 0 or tab.label ~= "BCB" then
- print("Carta non valida!")
- sleep(2)
- os.reboot()
- end
- rs.setOutput("left", false)
- print("Inserisci i soldi qua sotto e clicca un tasto\nqualunque quando hai fatto")
- os.pullEvent("key")
- rs.setOutput("left", true)
- print("Sto contando...")
- rednet.open("back")
- rednet.send(12, "conta")
- id, msg = rednet.receive()
- if id == 12 then
- ncredito = tab.credito + tonumber(msg)
- end
- tab.credito = ncredito
- print("Inserire nuovamente la carta per confermare")
- mag.beginWrite(textutils.serialize(tab), "BC Bank")
- os.pullEvent("mag_write_done")
- print("Nuovo credito: "..tostring(ncredito))
- sleep(3)
- os.reboot()
- end
- term.clear()
- term.setCursorPos(1,1)
- term.write("Banca Di BlueCity - Accredito su carta")
- term.setCursorPos(1, 3)
- print("[1] Inserisci soldi")
- term.setCursorPos(1, 5)
- term.write(">> ")
- s = read()
- if s == "1" then
- accredita()
- else
- os.reboot()
- end
- os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement