Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --ProximityDoor by KapitanWalnut
- --version 2.3
- --Redstone turns on when players are within range
- --NOTE: utilizes OpenPeripheral sensor
- local sensor = peripheral.wrap("left") --sensor location
- local output = "back" --output for door
- local initial = true --default state of redstone
- --Proximity to sensor for door to open
- local minX = -3 local maxX = 5
- local minY = 1 local maxY = 3
- local minZ = -3 local maxZ = 3
- --Initialize
- redstone.setOutput(output, initial)
- --Infinite loop
- while true do
- players = sensor.getPlayerNames()
- --stop checking if no players
- if #players == 0 then
- redstone.setOutput(output, initial)
- sleep(0.7)
- else --players in vicinity
- for _, name in pairs(players) do
- if name ~= "" then --player has a name (can put specific names here)
- info = sensor.getPlayerData(name)
- pos = info.position
- --check if within correct area
- if pos.x >= minX and pos.x <= maxX
- and pos.y >= minY and pos.y <= maxY
- and pos.z >= minZ and pos.z <= maxZ then
- redstone.setOutput(output, not initial)
- else
- redstone.setOutput(output, initial)
- end
- end
- end
- sleep(0.5)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment