Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- m = peripheral.wrap("right") --magcard
- lbl = "BN Credit"
- print("Porta a Pagamento(R)")
- print("")
- print("Inserire la carta")
- m.setInsertCardLight(true)
- za,rawCredito = os.pullEvent("mag_swipe")
- m.setInsertCardLight(false)
- credito = tonumber(rawCredito)
- while true do
- print("La carta ha una disponibilità di "..credito.." IC.")
- print("")
- print("Per favore scegliere un'opzione utilizzando i tasti numerici e confermare con ENTER:")
- print("")
- print("[1] Aprire la porta - Costo: 2 IC")
- print("[2] Annullare il pagamento")
- num=tonumber(read())
- if num == 1 then
- prelievo=2
- if prelievo > credito then
- clear()
- print("Disponibilità insufficiente")
- sleep(5)
- os.reboot()
- end
- clear()
- print("Inserire nuovamente la carta per confermare il pagamento")
- nuovoCredito = credito - prelievo
- ncr = tostring(nuovoCredito)
- m.setInsertCardLight(true)
- m.beginWrite(ncr,lbl)
- os.pullEvent("mag_write_done")
- m.setInsertCardLight(false)
- print("Porta perta")
- print("")
- redstone.setOutput("bottom", true)
- sleep(5)
- redstone.setOutput("bottom", false)
- 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