Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local detector = peripheral.find("playerDetector") -- Finds the peripheral if one is connected
- if detector == nil then error("playerDetector not found") end
- function getPlayers(int range)
- local players = detector.getPlayersInRange(range) --Returns a table of every player in a certain range
- for k,v in pairs(players) do --we use a for loop to print the names of every player
- print(v) --We print every player name
- end
- end
- function printPlayerCoords(player) --this function will print the coordinates of the player
- local pos = detector.getPlayerPos(player) --getPlayerPos returns a table with coordinates
- print("X of ".. player .." is: ".. pos.x)
- print("Y of ".. player .." is: ".. pos.y)
- print("Z of ".. player .." is: ".. pos.z)
- end
- getPlayers(50) --Will execute the function getPlayers
- printPlayerCoords("User") --Will execute the function printPlayerCords
- --Prints some information to the terminal of the computer
- while true do
- event, username = os.pullEvent("playerClick") --This event will fires when a player clicks on the block
- print("A player clicked the block: ".. username) --Prints the username of the player
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement