lego11

ACCREDITO

May 12th, 2018
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.06 KB | None | 0 0
  1. function clear()
  2. term.clear()
  3. term.setCursorPos(1,1)
  4. end
  5. clear()
  6. print("ACCREDITO SU CARTA")
  7. print("")
  8. print("Digitare 'a' per lettore davanti, 'd' per lettore dietro")
  9. local latouf = read()
  10. if latouf = "a" then
  11. local lato = "bottom"
  12. elseif latouf = "d" then
  13. local lato = "right"
  14. else
  15. print("Errore durante la selezione del lato")
  16. os.reboot()
  17. end
  18. m = peripheral.wrap(lato) --magcard
  19. lbl = "BN Credit"
  20. clear()
  21. m.setInsertCardLight(true)
  22. za,rawCredito = os.pullEvent("mag_swipe")
  23. m.setInsertCardLight(false)
  24. credito = tonumber(rawCredito)
  25. while true do
  26. print("La carta ha una disponibilità di "..credito.." IC.")
  27. print("")
  28. print("Inserire l'importo da accreditare")
  29. print("")
  30. local raccredito = read()
  31. local accredito = tonumber(raccredito)
  32. local nuovoCredito = credito + accredito
  33. local ncr = tostring(nuovoCredito)
  34. print("")
  35. print("INSERIRE LA CARTA NUOVAMENTE")
  36. m.setInsertCardLight(true)
  37. m.beginWrite(ncr,lbl)
  38. os.pullEvent("mag_write_done")
  39. m.setInsertCardLight(false)
  40. clear()
  41. print("Importo accreditato")
  42. print("")
  43. sleep(5)
  44. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment