Advertisement
supreamcallum45

Untitled

Jun 12th, 2021
682
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.97 KB | None | 0 0
  1. local speakers = table.pack(peripheral.find("speaker"))
  2. local playerDetector = table.pack(peripheral.find("playerDetector"))
  3. local RedstoneControl = peripheral.find("redstoneIntegrator")
  4. -- local chat = peripheral.find("chat")
  5.  
  6. local AllowedUser = "supreamcallum45"
  7.  
  8.  
  9.  
  10. function alarmsound()
  11.     -- while true do
  12.        
  13.         for i = 1, speakers.n do
  14.         speakers[i].playSound("minecraft:block.note_block.bell", 3, 0.5)
  15.         speakers[i].playSound("minecraft:block.note_block.bell", 3, 1)
  16.         speakers[i].playSound("minecraft:block.note_block.bell", 3, 1.5)
  17.         speakers[i].playSound("minecraft:block.note_block.bell", 3, 2)
  18.         speakers[i].playSound("minecraft:block.note_block.bell", 3, 1.5)
  19.         speakers[i].playSound("minecraft:block.note_block.bell", 3, 1)
  20.         speakers[i].playSound("minecraft:block.note_block.bell", 3, 0.5)
  21.         end
  22.         sleep(0.05)
  23.         print("ALARM")
  24.  
  25.     -- end
  26. end
  27.  
  28.  
  29. function getPlayers(range)
  30.     for o = 1, playerDetector.n do
  31.         local players = playerDetector[o].getPlayersInRange(range) --Returns a table of every player in a certain range
  32.         for k,v in pairs(players) do --we use a for loop to print the names of every player
  33.         -- print(v) --We print every player name
  34.         if AllowedUser ~= v then
  35.             alarmsound()
  36.         end
  37.         end
  38.     end
  39.   end
  40.  
  41.  
  42. --   function printPlayerCords(player) --this function will print the coordinates of the player
  43. --     for o = 1, playerDetector.n do
  44. --         local pos = playerDetector[o].getPlayerPos(player) --getPlayerPos returns a table with coordinates
  45. --         print("X of ".. player .." is: ".. pos.x)
  46. --         print("Y of ".. player .." is: ".. pos.y)
  47. --         print("Z of ".. player .." is: ".. pos.z)
  48. --     end
  49. --   end
  50.  
  51.  
  52. -- getPlayers(10)
  53. -- printPlayerCords("supreamcallum45")
  54.  
  55. -- alarmsound()
  56.  
  57. while true do
  58.  
  59.     while RedstoneControl.getInput("front") == true do
  60.  
  61.         getPlayers(10)
  62.  
  63.     end
  64. end
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement