Squanou

base

Jun 22nd, 2024 (edited)
566
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.71 KB | None | 0 0
  1. local detector = peripheral.find("playerDetector")
  2. if detector == nil then
  3.     print("Aucun détecteur de joueur disponible")
  4.     return
  5. end
  6.  
  7. local speaker = peripheral.find("speaker")
  8. if speaker == nil then
  9.     print("Aucun speaker disponible")
  10.     return
  11. end
  12.  
  13. local function detectAndAlert()
  14.     local players = detector.getPlayersInCoords({x = -19, y = 0, z = -18}, {x = -18, y = 1, z = -17})
  15.     if #players > 0 then
  16.         print("Joueur détecté à la position (-19, 0, -18)")
  17.         speaker.playNote("harp", 1, 12)
  18.     else
  19.         print("Aucun joueur détecté à la position (-19, 0, -18)")
  20.     end
  21. end
  22.  
  23. while true do
  24.     detectAndAlert()
  25.     sleep(1)  -- Vérifie toutes les secondes
  26. end
  27.  
Advertisement
Add Comment
Please, Sign In to add comment