Advertisement
fabrossmann

test

Nov 2nd, 2021
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1.  
  2. local detector = peripheral.find("playerDetector") -- Finds the peripheral if one is connected
  3.  
  4. if detector == nil then error("playerDetector not found") end
  5.  
  6. function getPlayers(int range)
  7. local players = detector.getPlayersInRange(range) --Returns a table of every player in a certain range
  8. for k,v in pairs(players) do --we use a for loop to print the names of every player
  9. print(v) --We print every player name
  10. end
  11. end
  12.  
  13. function printPlayerCoords(player) --this function will print the coordinates of the player
  14. local pos = detector.getPlayerPos(player) --getPlayerPos returns a table with coordinates
  15. print("X of ".. player .." is: ".. pos.x)
  16. print("Y of ".. player .." is: ".. pos.y)
  17. print("Z of ".. player .." is: ".. pos.z)
  18. end
  19.  
  20. getPlayers(50) --Will execute the function getPlayers
  21.  
  22. printPlayerCoords("User") --Will execute the function printPlayerCords
  23.  
  24. --Prints some information to the terminal of the computer
  25. while true do
  26. event, username = os.pullEvent("playerClick") --This event will fires when a player clicks on the block
  27. print("A player clicked the block: ".. username) --Prints the username of the player
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement