Advertisement
chekalin87

sensor

Jun 27th, 2015
642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. local co = require("component")
  2. local sen = co.motion_sensor
  3. local event = require("event")
  4. local sides = require("sides")
  5. local red = co.redstone
  6.  
  7. print("Порог чувствительности: ", sen.getSensitivity())
  8. print("Отключить сигнализацию - любая клавиша")
  9. print("Завершить программу - Q")
  10. print()
  11. print("Список посетителей:")
  12.  
  13. local name, n
  14. local q = true
  15. local quests = {}
  16. -- Вайтлист
  17. local whiteList = {"cloud", "LeShyj", "entity.Cat.name", "reload", "karnel"}
  18. -- Сирена
  19. local function sos()
  20.   local z = true
  21.   for i = 1, #whiteList do
  22.     if whiteList[i] == name then
  23.       z = false
  24.     end
  25.   end
  26.   if z then
  27.     red.setOutput(1, 15) -- Выдаёт сигнал сверху красного контроллера.
  28.   end
  29. end
  30.  
  31. while q do
  32.   local b = true
  33.   n, _, _, m, _, name = event.pull()
  34.   if n == "motion" then
  35.     for i = 1, #quests do
  36.       if quests[i] == name then
  37.         b = false
  38.       end
  39.     end
  40.     if b == true then
  41.       table.insert(quests, name)
  42.       print(name)
  43.       sos()
  44.     end
  45.   end
  46.   if n == "key_down" then
  47.     red.setOutput(1, 0)
  48.     if m == 16 then
  49.       q = false
  50.       print("Программа завершена.")
  51.     end
  52.   end
  53. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement