SHOW:
|
|
- or go back to the newest paste.
| 1 | function main() | |
| 2 | local chatBox = peripheral.find("chatBox")
| |
| 3 | local playerDetector = peripheral.find("playerDetector")
| |
| 4 | ||
| 5 | rednet.open("top")
| |
| 6 | ||
| 7 | while true do | |
| 8 | local playerToExpose = listenForRequest() | |
| 9 | ||
| 10 | local onlinePlayers = playerDetector.getOnlinePlayers() | |
| 11 | ||
| 12 | local foundPlayer = false | |
| 13 | for i, name in ipairs(onlinePlayers) do | |
| 14 | if name == playerToExpose then | |
| 15 | foundPlayer = true | |
| 16 | end | |
| 17 | end | |
| 18 | ||
| 19 | if foundPlayer then | |
| 20 | local playerPosition = playerDetector.getPlayerPos(playerToExpose) | |
| 21 | local message = "This you, "..playerToExpose..": ".. | |
| 22 | playerPosition.x.." ".. | |
| 23 | playerPosition.y.." ".. | |
| 24 | playerPosition.z.."?" | |
| 25 | ||
| 26 | chatBox.sendMessage(message) | |
| 27 | end | |
| 28 | end | |
| 29 | end | |
| 30 | ||
| 31 | function listenForRequest() | |
| 32 | _, playerName = rednet.receive("expose")
| |
| 33 | return playerName | |
| 34 | end | |
| 35 | ||
| 36 | main() |