Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local event = require('event')
- local com = require('component')
- local sensor = com.motion_sensor
- local rs = com.redstone
- local sides = require('sides')
- local whitelist = {"serafim","zombiman"} --список кого впускать
- local sideredstone = "right" --"left","right","front","back","bottom","top".
- local function redset(side, value)
- rs.setOutput(sides[side], value)
- end
- redset(sideredstone, 0)
- local function isUser(name)
- for i=1, #whitelist do
- if name == whitelist[i] then
- return true
- end
- end
- return false
- end
- while true do
- local _, address, x, y, z, name = event.pull('motion')
- --print("x "..math.ceil(x).." y "..math.ceil(y).." z "..math.ceil(z))
- print("замечен: "..name)
- if isUser(name) then
- print("дверь открыта")
- redset(sideredstone, 15)
- os.sleep(3) --время открытой двери
- redset(sideredstone, 0)
- else
- print("посторонним вход запрещен")
- os.sleep(3)
- print(" ")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement