Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. -- Requires OpenPeripheral Sensor block attached to computer.
  2. -- R.S. signal will output when you approach the door.
  3. -- Adjust the peripheral wrapping and min/max values.
  4. -- Can be set to enable/disable R.S. on detection.
  5. local users = {["m3ntalpain"] = true,
  6. ["phaNnYpacker86"] = true,
  7. ["JellieBaby"] = true,
  8. ["kellychris200"]}
  9. local sensor = peripheral.wrap("right") -- where the sensor is
  10. -- How close you need to be to the sensor in order to use it.
  11. local minX = -2 local maxX = 10
  12. local minY = 0 local maxY = 10
  13. local minZ = -2 local maxZ = 10
  14. -- Initial output
  15. redstone.setOutput("back", true)
  16. while true do
  17. players = sensor.getPlayerNames()
  18. -- Don't do checks if there are no players.
  19. if #players == 0 then
  20. redstone.setOutput("back", true)
  21. sleep(0.7)
  22. else -- There are players
  23. for _, name in pairs(players) do
  24. -- If the users listed in above ( local users ) then output is true.
  25. if users[name] then
  26. info = sensor.getPlayerData(name)
  27. pos = info.position
  28.  
  29. if pos.x >= minX and pos.x <= maxX
  30. and pos.y >= minY and pos.y <= maxY
  31. and pos.z >= minZ and pos.z <= maxZ then
  32. redstone.setOutput("back", false)
  33. break
  34. end
  35. end
  36. end
  37. -- There are players around, we need to be more responsive
  38. sleep(0.5)
  39. end
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement