Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local authorized = {"gollark", "Sascha_T", "Ale32bit"}
- local door = "left"
- local radar = peripheral.find "radar"
- local monitor = peripheral.find "monitor"
- local scan_distance, open_distance = 12, 3
- monitor.setTextScale(0.5)
- local auth_map = {}
- for _, v in pairs(authorized) do auth_map[v] = true end
- term.redirect(monitor)
- local was_open = false
- local function timestamp()
- return os.date "!%X"
- end
- while true do
- local players = radar.getPlayers(scan_distance)
- local open, player, others = false, nil, {}
- for _, p in pairs(players) do
- if not player and auth_map[p.name] and p.distance < open_distance then
- open = true
- player = p.name
- else
- table.insert(others, p.name)
- end
- end
- local others = table.concat(others, " ")
- if open and not was_open then
- local extra_text = ""
- if others ~= "" then
- extra_text = "+ " .. others
- end
- print(timestamp(), player, extra_text)
- end
- rs.setOutput(door, open)
- was_open = open
- sleep(0.2)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement