Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Requires OpenPeripheral Sensor block attached to computer.
- -- R.S. signal will output when you approach the door.
- -- Adjust the peripheral wrapping and min/max values.
- -- Can be set to enable/disable R.S. on detection.
- local users = {["m3ntalpain"] = true,
- ["phaNnYpacker86"] = true,
- ["JellieBaby"] = true,
- ["kellychris200"]}
- local sensor = peripheral.wrap("right") -- where the sensor is
- -- How close you need to be to the sensor in order to use it.
- local minX = -2 local maxX = 10
- local minY = 0 local maxY = 10
- local minZ = -2 local maxZ = 10
- -- Initial output
- redstone.setOutput("back", true)
- while true do
- players = sensor.getPlayerNames()
- -- Don't do checks if there are no players.
- if #players == 0 then
- redstone.setOutput("back", true)
- sleep(0.7)
- else -- There are players
- for _, name in pairs(players) do
- -- If the users listed in above ( local users ) then output is true.
- if users[name] then
- info = sensor.getPlayerData(name)
- pos = info.position
- 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("back", false)
- break
- end
- end
- end
- -- There are players around, we need to be more responsive
- sleep(0.5)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement