DabDaddy6223

player_detector

Jul 19th, 2026 (edited)
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | None | 0 0
  1. -- Usage:
  2. -- detector <x1> <y1> <z1> <x2> <y2> <z2>
  3.  
  4. local args = { ... }
  5.  
  6. if #args ~= 6 then
  7.     print("Usage: detector <x1> <y1> <z1> <x2> <y2> <z2>")
  8.     return
  9. end
  10.  
  11. local detector = peripheral.find("playerDetector")
  12. assert(detector, "Player Detector not found")
  13.  
  14. local posOne = {
  15.     x = tonumber(args[1]),
  16.     y = tonumber(args[2]),
  17.     z = tonumber(args[3])
  18. }
  19.  
  20. local posTwo = {
  21.     x = tonumber(args[4]),
  22.     y = tonumber(args[5]),
  23.     z = tonumber(args[6])
  24. }
  25.  
  26. while true do
  27.     local players = detector.getPlayersInCoords(posOne, posTwo)
  28.  
  29.     if #players > 0 then
  30.         print("Player Detected!")
  31.         redstone.setOutput("back", true)
  32.     else
  33.         redstone.setOutput("back", false)
  34.     end
  35.  
  36.     sleep(0.1)
  37. end
Advertisement
Add Comment
Please, Sign In to add comment