Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sens = peripheral.wrap("left")
- local outside = "top"
- local door = false
- local radius = 5
- door = false
- redstone.setOutput(outside, (not door))
- function getPos(username)
- local ok, player = pcall(sens.getPlayerByName, username)
- if ok then
- return player.select("living").position
- end
- end
- function chkDoor()
- redstone.setOutput(outside, (not door))
- end
- function chkPlayer()
- local players = sens.getPlayers()
- if #players ~= 0 then
- for k=1,#players do
- local pos = getPos(players[k].name)
- if pos and pos.x >= (radius * -1) and pos.x <= radius
- and pos.y >= (radius * -1) and pos.y <= radius
- and pos.z >= (radius * -1) and pos.z <= radius then
- -- print(username.."is in the spot. Opening Door.")
- door = true
- return
- end
- end
- end
- door = false
- end
- while true do
- sleep(0.5)
- chkDoor()
- chkPlayer()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement