Advertisement
MrDionesalvi

Security 1

Oct 15th, 2020 (edited)
809
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.41 KB | None | 0 0
  1. ---  Calafrica Group Security
  2. ---
  3. --- v 1.0
  4. ---
  5.  
  6.  
  7. os.loadAPI("ocs/apis/sensor")
  8.  
  9. --LATO SENSORE
  10. se = sensor.wrap("top")
  11.  
  12. --LATO ATTIVAZIONE REDSTONE
  13. lato = "front"
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21. --GIOCATORI PER CUI SI SPEGNE
  22. giocatore1 = "dionesalvi"
  23. giocatore2 = ""
  24. giocatore3 = ""
  25.  
  26. rs.setOutput(lato, false)
  27.  
  28. function check()
  29.     os.loadAPI("ocs/apis/sensor")
  30.     check = 0
  31.     while 6 do
  32.         ta = se.getTargets()
  33.             for k,v in pairs(ta) do
  34.                 if v["Name"] == "Player" and k ~= "lego11" and k ~= giocatore1 and k ~= giocatore2 and k ~= giocatore3 then
  35.                     print("Rilevato giocatore non autorizzato: "..k)
  36.                     check = 1
  37.             end
  38.    
  39.     end
  40. return check
  41. end
  42.  
  43. function checks()
  44.     os.loadAPI("ocs/apis/sensor")
  45.     checks = check()
  46.     while 6 do
  47.         ta = se.getTargets()
  48.             for k,v in pairs(ta) do
  49.                 if v["Name"] == "Player" and k == "lego11" and k == giocatore1 and k == giocatore2 and k == giocatore3 then
  50.                     print("Rilevato giocatore autorizzato: "..k)
  51.                     checks = 0
  52.                 end
  53.             end
  54.     end
  55.  
  56.     return checks
  57. end
  58.  
  59.  
  60.  
  61.  
  62. os.loadAPI("ocs/apis/sensor")
  63. while true do
  64.  
  65.     if checks() == 1 then
  66.  
  67.         if checks() == 1 then
  68.  
  69.             rs.setOutput(lato, true)
  70.  
  71.         end
  72.  
  73.     end
  74.     sleep(0.2)
  75.     rs.setOutput(lato, false)
  76.  
  77. end
  78.  
  79.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement