Advertisement
MrDionesalvi

ApriPorta finale

Jul 5th, 2019
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.13 KB | None | 0 0
  1. --c Zeus S.p.A 2019
  2. os.pullEvent = os.pullEventRaw
  3. local lbl = "Hotel1"
  4. local tabr = {}
  5. local m = peripheral.wrap("top")
  6. rs.setOutput("left", false)
  7. function clear()
  8. term.clear()
  9. term.setCursorPos(1,1)
  10. end
  11.  
  12.  
  13. function cartaNonValida()
  14. clear()
  15. print("Carta non valida o corrotta.")
  16. print("")
  17. print("Premere un tasto per uscire")
  18. os.reboot()
  19. end
  20.  
  21. function cartaVuota()
  22. clear()
  23. print("")
  24. print("Premere un tasto per uscire")
  25. os.pullEvent("key")
  26. clear()
  27. os.reboot()
  28. end
  29.  
  30.  
  31. clear()
  32. print("Apri la porta")
  33. print("")
  34. print("Inserire la carta")
  35.  
  36. m.setInsertCardLight(true)
  37. za,rawcarta = os.pullEvent("mag_swipe")
  38. m.setInsertCardLight(false)
  39.  
  40. if rawcarta == nil then
  41. cartaVuota()
  42. end
  43.  
  44. tab = textutils.unserialize(rawcarta)
  45.  
  46. if type(tab) ~= "table" then
  47. cartaNonValida()
  48. end
  49.  
  50. if tab.t ~= "Hotel" then
  51. cartaNonValida()
  52. end
  53.  
  54. if tab.e ~= "1" and tab.e ~= "sar34" then
  55. cartaNonValida()
  56. end
  57.  
  58. print("Numero stanza:")
  59. print(tab.e)
  60.  
  61. print("\nCredito rimanente: ")
  62. print(tab.p)
  63.  
  64. print("\nBene hai aperto la porta")
  65. rs.setOutput("left", true)
  66. sleep(2)
  67. rs.setOutput("left", false)
  68. clear()
  69. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement