Advertisement
MrDionesalvi

ApriPorta2

Jul 5th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.15 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.pullEvent("key")
  19. os.reboot()
  20. end
  21.  
  22. function cartaVuota()
  23. clear()
  24. print("")
  25. print("Premere un tasto per uscire")
  26. os.pullEvent("key")
  27. clear()
  28. exit()
  29. end
  30.  
  31.  
  32. clear()
  33. print("Apri la porta")
  34. print("")
  35. print("Inserire la carta")
  36.  
  37. m.setInsertCardLight(true)
  38. za,rawcarta = os.pullEvent("mag_swipe")
  39. m.setInsertCardLight(false)
  40.  
  41. if rawcarta == nil then
  42. cartaVuota()
  43. end
  44.  
  45. tab = textutils.unserialize(rawcarta)
  46.  
  47. if type(tab) ~= "table" then
  48. cartaNonValida()
  49. end
  50.  
  51. if tab.t ~= "Hotel" then
  52. cartaNonValida()
  53. end
  54.  
  55. if tab.e ~= "1" and tab.e ~= "sar34" then
  56. cartaNonValida()
  57. end
  58.  
  59. print("Numero stanza:")
  60. print(tab.e)
  61.  
  62. print("\nCredito rimanente: ")
  63. print(tab.p)
  64.  
  65. print("\nBene hai aperto la porta")
  66. rs.setOutput("left", true)
  67. sleep(2)
  68. rs.setOutput("left", false)
  69. clear()
  70. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement